Changeset 38897 in vbox for trunk/src/VBox/Devices/PC
- Timestamp:
- Sep 28, 2011 1:33:26 PM (13 years ago)
- Location:
- trunk/src/VBox/Devices/PC/BIOS-new
- Files:
-
- 2 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/PC/BIOS-new/ahci.c
r38851 r38897 26 26 #include "ebda.h" 27 27 #include "inlines.h" 28 #include "pciutil.h" 28 29 29 30 #define VBOX_AHCI_DEBUG 0 … … 76 77 * to save memory. - Must be aligned on a 1K boundary. 77 78 */ 78 uint32_t a bCmdHdr[0x8];79 uint32_t aCmdHdr[0x8]; 79 80 /** Align the next structure on a 128 byte boundary. */ 80 81 uint8_t abAlignment1[0x60]; … … 113 114 #define AhciData ((ahci_t *) 0) 114 115 115 /** Supported methods of the PCI BIOS. */116 #define PCIBIOS_ID 0xb1117 #define PCIBIOS_PCI_BIOS_PRESENT 0x01118 #define PCIBIOS_FIND_PCI_DEVICE 0x02119 #define PCIBIOS_FIND_CLASS_CODE 0x03120 #define PCIBIOS_GENERATE_SPECIAL_CYCLE 0x06121 #define PCIBIOS_READ_CONFIG_BYTE 0x08122 #define PCIBIOS_READ_CONFIG_WORD 0x09123 #define PCIBIOS_READ_CONFIG_DWORD 0x0a124 #define PCIBIOS_WRITE_CONFIG_BYTE 0x0b125 #define PCIBIOS_WRITE_CONFIG_WORD 0x0c126 #define PCIBIOS_WRITE_CONFIG_DWORD 0x0d127 #define PCIBIOS_GET_IRQ_ROUTING_OPTIONS 0x0e128 #define PCIBIOS_SET_PCI_IRQ 0x0f129 130 /** Status codes. */131 #define SUCCESSFUL 0x00132 #define FUNC_NOT_SUPPORTED 0x81133 #define BAD_VENDOR_ID 0x83134 #define DEVICE_NOT_FOUND 0x86135 #define BAD_REGISTER_NUMBER 0x87136 #define SET_FAILED 0x88137 #define BUFFER_TOO_SMALL 0x89138 139 116 /** PCI configuration fields. */ 140 117 #define PCI_CONFIG_CAP 0x34 … … 210 187 211 188 212 /* Warning: Destroys high bits of ECX. */213 uint16_t pci_find_class(uint16_t op, uint32_t dev_class, uint16_t start_bdf);214 #pragma aux pci_find_class = \215 ".386" \216 "shl ecx, 16" \217 "mov cx, dx" \218 "int 0x1a" \219 "cmp ah, 0" \220 "je found" \221 "mov bx, 0xffff" \222 "found:" \223 parm [ax] [cx dx] [si] value [bx];224 225 uint16_t pci_read_cfgw(uint16_t op, uint16_t bus_dev_fn, uint16_t reg);226 #pragma aux pci_read_cfgw = \227 "int 0x1a" \228 parm [ax] [bx] [di] value [cx];229 230 uint8_t pci_read_cfgb(uint16_t op, uint16_t bus_dev_fn, uint16_t reg);231 #pragma aux pci_read_cfgb = \232 "int 0x1a" \233 parm [ax] [bx] [di] value [cx];234 235 /* Warning: Destroys high bits of ECX. */236 uint32_t pci_read_cfgd(uint16_t op, uint16_t bus_dev_fn, uint16_t reg);237 #pragma aux pci_read_cfgd = \238 ".386" \239 "int 0x1a" \240 "mov ax, cx" \241 "shr ecx, 16" \242 parm [ax] [bx] [di] value [cx ax];243 244 189 /* Warning: Destroys high bits of EAX. */ 245 190 uint32_t inpd(uint16_t port); … … 263 208 264 209 /** 265 * Returns the bus/device/function of a PCI device with266 * the given class code.267 *268 * @returns bus/device/fn in a 16-bit integer where269 * where the upper byte contains the bus number270 * and lower one the device and function number.271 * VBOX_AHCI_NO_DEVICE if no device was found.272 * @param dev_class The PCI class code to search for.273 */274 uint16_t pci_find_classcode(uint32_t dev_class)275 {276 return pci_find_class((PCIBIOS_ID << 8) | PCIBIOS_FIND_CLASS_CODE, dev_class, 0);277 }278 279 uint32_t pci_read_config_byte(uint8_t bus, uint8_t dev_fn, uint8_t reg)280 {281 return pci_read_cfgw((PCIBIOS_ID << 8) | PCIBIOS_READ_CONFIG_BYTE, (bus << 8) | dev_fn, reg);282 }283 284 uint32_t pci_read_config_word(uint8_t bus, uint8_t dev_fn, uint8_t reg)285 {286 return pci_read_cfgw((PCIBIOS_ID << 8) | PCIBIOS_READ_CONFIG_WORD, (bus << 8) | dev_fn, reg);287 }288 289 uint32_t pci_read_config_dword(uint8_t bus, uint8_t dev_fn, uint8_t reg)290 {291 return pci_read_cfgd((PCIBIOS_ID << 8) | PCIBIOS_READ_CONFIG_DWORD, (bus << 8) | dev_fn, reg);292 }293 294 #if 0 /* Disabled to save space because they are not needed. Might become useful in the future. */295 /**296 * Returns the bus/device/function of a PCI device with297 * the given vendor and device id.298 *299 * @returns bus/device/fn in one 16bit integer where300 * where the upper byte contains the bus number301 * and lower one the device and function number.302 * VBOX_AHCI_NO_DEVICE if no device was found.303 * @param u16Vendor The vendor ID.304 * @param u16Device The device ID.305 */306 uint16_t pci_find_device(uint16_t u16Vendor, uint16_t u16Device)307 {308 uint16_t u16BusDevFn;309 310 ASM_START311 push bp312 mov bp, sp313 314 mov ah, #PCIBIOS_ID315 mov al, #PCIBIOS_FIND_PCI_DEVICE316 mov cx, _pci_find_device.u16Device + 2[bp]317 mov dx, _pci_find_device.u16Vendor + 2[bp]318 mov si, #0 ; First controller319 int 0x1a320 321 ; Return from PCIBIOS322 cmp ah, #SUCCESSFUL323 jne pci_find_device_not_found324 325 mov _pci_find_device.u16BusDevFn + 2[bp], bx326 jmp pci_find_device_done327 328 pci_find_device_not_found:329 mov _pci_find_device.u16BusDevFn + 2[bp], #VBOX_AHCI_NO_DEVICE330 331 pci_find_device_done:332 pop bp333 ASM_END334 335 return u16BusDevFn;336 }337 338 void pci_write_config_byte(u8Bus, u8DevFn, u8Reg, u8Val)339 uint8_t u8Bus, u8DevFn, u8Reg, u8Val;340 {341 ASM_START342 push bp343 mov bp, sp344 345 mov ah, #PCIBIOS_ID346 mov al, #PCIBIOS_WRITE_CONFIG_BYTE347 mov bh, _pci_write_config_byte.u8Bus + 2[bp]348 mov bl, _pci_write_config_byte.u8DevFn + 2[bp]349 mov di, _pci_write_config_byte.u8Reg + 2[bp]350 mov cl, _pci_write_config_byte.u8Val + 2[bp]351 int 0x1a352 353 ; Return from PCIBIOS354 pop bp355 ASM_END356 }357 358 void pci_write_config_word(uint8_t u8Bus, uint8_t u8DevFn, uint8_t u8Reg, uint16_t u16Val)359 {360 ASM_START361 push bp362 mov bp, sp363 364 mov ah, #PCIBIOS_ID365 mov al, #PCIBIOS_WRITE_CONFIG_WORD366 mov bh, _pci_write_config_word.u8Bus + 2[bp]367 mov bl, _pci_write_config_word.u8DevFn + 2[bp]368 mov di, _pci_write_config_word.u8Reg + 2[bp]369 mov cx, _pci_write_config_word.u16Val + 2[bp]370 int 0x1a371 372 ; Return from PCIBIOS373 pop bp374 ASM_END375 }376 377 void pci_write_config_dword(uint8_t u8Bus, uint8_t u8DevFn, uint8_t u8Reg, uint32_t u32Val)378 {379 ASM_START380 push bp381 mov bp, sp382 383 mov ah, #PCIBIOS_ID384 mov al, #PCIBIOS_WRITE_CONFIG_WORD385 mov bh, _pci_write_config_dword.u8Bus + 2[bp]386 mov bl, _pci_write_config_dword.u8DevFn + 2[bp]387 mov di, _pci_write_config_dword.u8Reg + 2[bp]388 mov cx, _pci_write_config_dword.u32Val + 2[bp]389 int 0x1a390 391 ; Return from PCIBIOS392 pop bp393 ASM_END394 }395 #endif /* 0 */396 397 /**398 210 * Sets a given set of bits in a register. 399 211 */ … … 465 277 u32Val |= cFisDWords; 466 278 467 ahci->a bCmdHdr[0] = u32Val;468 ahci->a bCmdHdr[1] = cbData;469 ahci->a bCmdHdr[2] = ahci_addr_to_phys(&ahci->abCmd[0]);279 ahci->aCmdHdr[0] = u32Val; 280 ahci->aCmdHdr[1] = cbData; 281 ahci->aCmdHdr[2] = ahci_addr_to_phys(&ahci->abCmd[0]); 470 282 471 283 /* Enable Command and FIS receive engine. */ … … 562 374 */ 563 375 //@todo: merge memsets? 564 _fmemset(&ahci->a bCmdHdr[0], 0, 0x20);376 _fmemset(&ahci->aCmdHdr[0], 0, 0x20); 565 377 _fmemset(&ahci->abCmd[0], 0, 0x84); 566 378 _fmemset(&ahci->abFisRecv[0], 0, 0x60); … … 606 418 */ 607 419 //@todo: just one memset? 608 _fmemset(&ahci->a bCmdHdr[0], 0, sizeof(ahci->abCmdHdr));420 _fmemset(&ahci->aCmdHdr[0], 0, sizeof(ahci->aCmdHdr)); 609 421 _fmemset(&ahci->abCmd[0], 0, sizeof(ahci->abCmd)); 610 422 _fmemset(&ahci->abFisRecv[0], 0, sizeof(ahci->abFisRecv)); … … 615 427 VBOXAHCI_PORT_WRITE_REG(u16IoBase, u8Port, AHCI_REG_PORT_FBU, 0); 616 428 617 u32PhysAddr = ahci_addr_to_phys(&ahci->a bCmdHdr);429 u32PhysAddr = ahci_addr_to_phys(&ahci->aCmdHdr); 618 430 VBOXAHCI_DEBUG("AHCI: CMD list area %lx\n", u32PhysAddr); 619 431 VBOXAHCI_PORT_WRITE_REG(u16IoBase, u8Port, AHCI_REG_PORT_CLB, u32PhysAddr); -
trunk/src/VBox/Devices/PC/BIOS-new/makefile
r38848 r38897 31 31 keyboard.obj disk.obj serial.obj system.obj timepci.obj & 32 32 ps2mouse.obj parallel.obj logo.obj scsi.obj ahci.obj & 33 pci bio32.obj orgs.obj33 pciutil.obj pcibio32.obj orgs.obj 34 34 35 35 vbxbios.rom : vbxbios.bin
Note:
See TracChangeset
for help on using the changeset viewer.