VirtualBox

Changeset 42127 in vbox for trunk/src/VBox/Devices/PC


Ignore:
Timestamp:
Jul 12, 2012 3:21:46 PM (13 years ago)
Author:
vboxsync
Message:

BIOS: Updating PCI BIOS service.

Location:
trunk/src/VBox/Devices/PC/BIOS
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/PC/BIOS/Makefile.kmk

    r42075 r42127  
    7575        system.c \
    7676        timepci.c \
     77        pcibios.c \
    7778        ps2mouse.c \
    7879        parallel.c \
  • trunk/src/VBox/Devices/PC/BIOS/inlines.h

    r39355 r42127  
    6969    parm [es di] [dx si] [cx];
    7070
     71#ifndef __386__
     72
    7173char __far *rep_insb(char __far *buffer, unsigned nbytes, unsigned port);
    7274#pragma aux rep_insb = ".286" "rep insb" parm [es di] [cx] [dx] value [es di] modify exact [cx di];
     
    9698    "xchg   ax, dx"     \
    9799    parm [dx ax] value [dx ax] modify exact [dx ax] nomemory;
     100
     101#endif
  • trunk/src/VBox/Devices/PC/BIOS/makefile

    r39372 r42127  
    1010#
    1111!ifdef __UNIX__
    12 QUOTE=\"
     12Q=\"
    1313!else
    14 QUOTE="
     14Q="
    1515!endif
    16 CFLAGS = -q -0 -wx -zu -s -oas -d1+ -ms
    17 DEFS   = -DVBOX -DVBOX_LANBOOT_SEG=0xE200 -DVBOX_VERSION_STRING=$(QUOTE)0.9$(QUOTE) &
     16CFLAGS   = -q -0 -wx -zu -s -oas -d1+ -ms
     17CFLAGS32 = -q -wx -zu -s -oas -d1+ -nt=BIOS32 -nd=BIOS32
     18
     19DEFS = -DVBOX -DVBOX_LANBOOT_SEG=0xE200 -DVBOX_VERSION_STRING=$(Q)0.9$(Q) &
    1820 -DVBOX_WITH_SCSI -DVBOX_WITH_AHCI
    1921
    2022AFLAGS = -q -0 -wx
    2123
    22 INCLS  = -I$(QUOTE)../../../../../include$(QUOTE)
     24INCLS  = -I$(Q)../../../../../include$(Q)
    2325
    2426.c.obj : .autodepend
     
    3133        keyboard.obj disk.obj serial.obj system.obj timepci.obj &
    3234        ps2mouse.obj parallel.obj logo.obj scsi.obj ahci.obj &
    33         pciutil.obj vds.obj pcibio32.obj orgs.obj
     35        pcibios.obj pciutil.obj vds.obj pcibio32.obj pci32.obj orgs.obj
    3436
    3537vbxbios.rom : vbxbios.bin
     
    4345         clname CODE &
    4446         segment _TEXT segaddr=0xF000 offset=0x1600 &
    45          segment BIOS32 segaddr=0xF000 offset=0xDE00 &
     47         segment BIOS32 segaddr=0xF000 offset=0xDB00 &
    4648         segment BIOSSEG segaddr=0xF000 offset=0xE000 &
    4749         file { $(OBJS) } &
     
    5254        wcc -fo=.obj $(INCLS) $(CFLAGS) $(DEFS) -DVBOX_PC_BIOS $<
    5355
     56pci32.obj : pci32.c .autodepend
     57        wcc386 -fo=.obj $(INCLS) $(DEFS) $(CFLAGS32) $<
     58
    5459clean : .symbolic
    5560        @rm -f *.obj *.err
  • trunk/src/VBox/Devices/PC/BIOS/orgs.asm

    r41655 r42127  
    111111extrn           _int1a_function:near
    112112extrn           _int1a_function_pci:near
     113extrn           _pci16_function:near
    113114extrn           _int70_function:near
    114115extrn           _int74_function:near
     
    16451646                jne     int1a_normal
    16461647
     1648if 0
    16471649                call    pcibios_real
    16481650                jc      pcibios_error
     
    16601662                popa
    16611663                iret
     1664else
     1665                push    es
     1666                push    ds
     1667                C_SETUP
     1668                .386
     1669                pushad
     1670                call    _pci16_function
     1671                popad
     1672                .286
     1673                pop     ds
     1674                pop     es
     1675                iret
     1676endif
    16621677
    16631678int1a_normal:
  • trunk/src/VBox/Devices/PC/BIOS/pcibio32.asm

    r41991 r42127  
    108108align 16
    109109pcibios_protected:
     110if 1
     111;; The old implementation of pcibios_protected will eventually go,
     112;; replaced by C code.
     113else
     114
     115extrn   _pci32_function:near
     116
     117                pushfd
     118                pushad
     119                call    _pci32_function
     120                popad
     121                popfd
     122                retf
     123endif
    110124                pushfd
    111125                cli
  • trunk/src/VBox/Devices/PC/BIOS/pcibios.c

    r42030 r42127  
    6363#define BP      r.gr.u.r16.bp
    6464#define SP      r.gr.u.r16.sp
    65 #define FLAGS   r.ra.flags.u.r16.flags
    6665#define EAX     r.gr.u.r32.eax
    6766#define EBX     r.gr.u.r32.ebx
     
    9089#define PCI_CFG_ADDR    0xCF8
    9190#define PCI_CFG_DATA    0xCFC
     91
     92#ifdef __386__
     93
     94#define PCIxx(x)    pci32_##x
     95
     96/* The stack layout is different in 32-bit mode. */
     97typedef struct {
     98    pushad_regs_t   gr;
     99    uint32_t        flags;
     100} pci_regs_t;
     101
     102#define FLAGS   r.flags
     103
     104/* In 32-bit mode, don't do any output; not technically impossible but needs
     105 * a lot of extra code.
     106 */
     107#undef  BX_INFO
     108#define BX_INFO(...)
     109#undef  BX_DEBUG_PCI
     110#define BX_DEBUG_PCI(...)
     111
     112#else
     113
     114#define PCIxx(x)    pci16_##x
     115
     116typedef struct {
     117    pushad_regs_t   gr;
     118    uint16_t        es;
     119    uint16_t        ds;
     120    iret_addr_t     ra;
     121} pci_regs_t;
     122
     123#define FLAGS   r.ra.flags.u.r16.flags
     124
     125#endif
     126
     127#ifdef __386__
     128
     129/* 32-bit code can just use the compiler intrinsics. */
     130extern unsigned inpd(unsigned port);
     131extern unsigned outpd(unsigned port, unsigned value);
     132#pragma intrinsic(inpd,outpd)
     133
     134#else
    92135
    93136//@todo: merge with AHCI code
     
    113156    parm [dx] [cx ax] modify nomemory;
    114157
     158#endif
     159
    115160/* Write the CONFIG_ADDRESS register to prepare for data access. Requires
    116161 * the register offset to be DWORD aligned (low two bits clear). Warning:
     
    131176 * This is largely a wrapper to avoid excessive inlining.
    132177 */
    133 void pci16_select_reg(uint16_t bus_dev_fn, uint16_t ofs)
     178void PCIxx(select_reg)(uint16_t bus_dev_fn, uint16_t ofs)
    134179{
    135180    pci16_w_addr(bus_dev_fn, ofs & ~3, PCI_CFG_ADDR);
    136181}
    137182
     183/* Selected configuration space offsets. */
    138184#define PCI_VEN_ID          0x00
    139185#define PCI_DEV_ID          0x02
     
    141187#define PCI_CLASS_CODE      0x09
    142188#define PCI_HEADER_TYPE     0x0E
    143 
     189#define PCI_BRIDGE_SUBORD   0x1A
     190
     191/* To avoid problems with 16-bit code, we reserve the last possible
     192 * bus/dev/fn combination (65,535). Upon reaching this location, the
     193 * probing will end.
     194 */
     195#define INDEX_NOT_FOUND     0xFFFF
    144196
    145197/* Find a specified PCI device, either by vendor+device ID or class.
     
    151203 * non-present devices.
    152204 */
    153 uint16_t pci16_find_device(uint32_t search_item, uint16_t index, int search_class)
     205uint16_t PCIxx(find_device)(uint32_t search_item, uint16_t index, int search_class)
    154206{
    155207    uint32_t    data;
     
    157209    uint8_t     max_bus;
    158210    uint8_t     hdr_type;
     211    uint8_t     subordinate;
    159212    int         step;
    160213    int         found;
     
    179232         */
    180233        if ((bus_dev_fn & 7) == 0) {
    181             pci16_select_reg(bus_dev_fn, PCI_HEADER_TYPE);
     234            PCIxx(select_reg)(bus_dev_fn, PCI_HEADER_TYPE);
    182235            hdr_type = inp(PCI_CFG_DATA + (PCI_HEADER_TYPE & 3));
    183236            if (hdr_type == 0xFF) {
     
    196249         * there will be only the primary bus (i.e. bus 0) and we can avoid
    197250         * looking at the remaining 255 theoretically present buses. This check
    198          * only needs to be done on the primary bus (bridges must report all
    199          * bridges behind them).
     251         * only needs to be done on the primary bus, since bridges must report
     252         * all bridges potentially behind them.
    200253         */
    201254        if ((hdr_type & 7) == 1 && (bus_dev_fn >> 8) == 0) {
     255            /* Read the subordinate (last) bridge number. */
     256            PCIxx(select_reg)(bus_dev_fn, PCI_BRIDGE_SUBORD);
     257            subordinate = inp(PCI_CFG_DATA + (PCI_BRIDGE_SUBORD & 3));
     258            if (subordinate > max_bus)
     259                max_bus = subordinate;
    202260        }
    203261
    204262        /* Select the appropriate register. */
    205         pci16_select_reg(bus_dev_fn, search_class ? PCI_REV_ID : PCI_VEN_ID);
     263        PCIxx(select_reg)(bus_dev_fn, search_class ? PCI_REV_ID : PCI_VEN_ID);
    206264        data  = inpd(PCI_CFG_DATA);
    207265        found = 0;
     
    226284    } while ((bus_dev_fn >> 8) <= max_bus);
    227285
    228     if (index == ~0)
     286    if (index == INDEX_NOT_FOUND)
    229287        BX_DEBUG_PCI("PCI: Device found (%02X:%%02X:%01X)\n", bus_dev_fn >> 8,
    230288                     bus_dev_fn >> 3 & 31, bus_dev_fn & 7);
    231289
    232     return index == ~0 ? bus_dev_fn : ~0;
     290    return index == INDEX_NOT_FOUND ? bus_dev_fn : INDEX_NOT_FOUND;
    233291}
    234292
    235 void BIOSCALL pci16_function(volatile pci_regs_t r)
     293void BIOSCALL PCIxx(function)(volatile pci_regs_t r)
    236294{
    237295    uint16_t    device;
     
    254312         * be easily detected.
    255313         */
    256         if (DX == ~0) {
     314        if (DX == 0xFFFF) {
    257315            SET_AH(BAD_VENDOR_ID);
    258316            SET_CF();
    259317        } else {
    260             device = pci16_find_device(DX | (uint32_t)CX << 16, SI, 0);
    261             if (device == ~0) {
     318            device = PCIxx(find_device)(DX | (uint32_t)CX << 16, SI, 0);
     319            if (device == INDEX_NOT_FOUND) {
    262320                SET_AH(DEVICE_NOT_FOUND);
    263321                SET_CF();
     
    268326        break;
    269327    case FIND_PCI_CLASS_CODE:
    270         device = pci16_find_device(ECX, SI, 1);
    271         if (device == ~0) {
     328        device = PCIxx(find_device)(ECX, SI, 1);
     329        if (device == INDEX_NOT_FOUND) {
    272330            SET_AH(DEVICE_NOT_FOUND);
    273331            SET_CF();
     
    286344            SET_CF();
    287345        } else {
    288             pci16_select_reg(BX, DI);
     346            PCIxx(select_reg)(BX, DI);
    289347            switch (GET_AL()) {
    290348            case READ_CONFIG_BYTE:
Note: See TracChangeset for help on using the changeset viewer.

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