VirtualBox

Changeset 18580 in vbox for trunk/src/VBox/Devices


Ignore:
Timestamp:
Mar 31, 2009 3:39:47 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
45477
Message:

Merged bios_printf changes from bochs.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/PC/BIOS/rombios.c

    r18574 r18580  
    16261626}
    16271627
    1628 #ifdef VBOX
    1629 void put_str(action, s)
     1628void put_str(action, segment, offset)
    16301629  Bit16u action;
    1631   Bit8u *s;
     1630  Bit16u segment;
     1631  Bit16u offset;
    16321632{
    16331633  Bit8u c;
    1634   if (!s)
    1635     s = "<NULL>";
    1636 
    1637   while (c = read_byte(get_CS(), s)) {
     1634
     1635  while (c = read_byte(segment, offset)) {
    16381636    send(action, c);
    1639     s++;
     1637    offset++;
    16401638  }
    16411639}
    1642 #endif /* VBOX */
     1640
    16431641
    16441642//--------------------------------------------------------------------------
    16451643// bios_printf()
    1646 //   A compact variable argument printf function which prints its output via
    1647 //   an I/O port so that it can be logged by Bochs/Plex.
    1648 //   Currently, only %x is supported (or %02x, %04x, etc).
     1644//   A compact variable argument printf function.
    16491645//
    1650 //   Supports %[format_width][format]
    1651 //   where format can be d,x,c,s
     1646//   Supports %[format_width][length]format
     1647//   where format can be x,X,u,d,s,S,c
     1648//   and the optional length modifier is l (ell)
    16521649//--------------------------------------------------------------------------
    16531650  void
     
    16601657  short i;
    16611658  Bit16u  *arg_ptr;
    1662   Bit16u   arg_seg, arg, nibble, hibyte, shift_count, format_width;
     1659  Bit16u   arg_seg, arg, nibble, hibyte, shift_count, format_width, hexadd;
    16631660
    16641661  arg_ptr = &s;
     
    16871684        arg_ptr++; // increment to next arg
    16881685        arg = read_word(arg_seg, arg_ptr);
    1689         if (c == 'x') {
     1686        if (c == 'x' || c == 'X') {
    16901687          if (format_width == 0)
    16911688            format_width = 4;
     1689          if (c == 'x')
     1690            hexadd = 'a';
     1691          else
     1692            hexadd = 'A';
    16921693          for (i=format_width-1; i>=0; i--) {
    16931694            nibble = (arg >> (4 * i)) & 0x000f;
    1694             send (action, (nibble<=9)? (nibble+'0') : (nibble-10+'A'));
     1695            send (action, (nibble<=9)? (nibble+'0') : (nibble-10+hexadd));
    16951696            }
    16961697          }
     
    17001701        else if (c == 'l') {
    17011702          s++;
     1703          c = read_byte(get_CS(), s); /* is it ld,lx,lu? */
    17021704          arg_ptr++; /* increment to next arg */
    17031705          hibyte = read_word(arg_seg, arg_ptr);
    1704           put_luint(action, ((Bit32u) hibyte << 16) | arg, format_width, 0);
     1706          if (c == 'd') {
     1707            if (hibyte & 0x8000)
     1708              put_luint(action, 0L-(((Bit32u) hibyte << 16) | arg), format_width-1, 1);
     1709            else
     1710              put_luint(action, ((Bit32u) hibyte << 16) | arg, format_width, 0);
     1711           }
     1712          else if (c == 'u') {
     1713            put_luint(action, ((Bit32u) hibyte << 16) | arg, format_width, 0);
     1714           }
     1715          else if (c == 'x' || c == 'X')
     1716           {
     1717            if (format_width == 0)
     1718              format_width = 8;
     1719            if (c == 'x')
     1720              hexadd = 'a';
     1721            else
     1722              hexadd = 'A';
     1723            for (i=format_width-1; i>=0; i--) {
     1724              nibble = ((((Bit32u) hibyte <<16) | arg) >> (4 * i)) & 0x000f;
     1725              send (action, (nibble<=9)? (nibble+'0') : (nibble-10+hexadd));
     1726              }
     1727           }
    17051728          }
    17061729        else if (c == 'd') {
     
    17111734          }
    17121735        else if (c == 's') {
    1713 #ifndef VBOX
    1714           bios_printf(action & (~BIOS_PRINTF_HALT), arg);
    1715 #else /* VBOX */
    1716           put_str(action, arg);
    1717 #endif /* VBOX */
     1736          put_str(action, get_CS(), arg);
     1737          }
     1738        else if (c == 'S') {
     1739          hibyte = arg;
     1740          arg_ptr++;
     1741          arg = read_word(arg_seg, arg_ptr);
     1742          put_str(action, hibyte, arg);
    17181743          }
    17191744        else if (c == 'c') {
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette