Здраствуй многоуважаемый ALL! Делаю драйверную имплементацию работы с PCIBIOS под виндос. Найден кусок памяти с сервисными функциями: PCIBIOS_PCI_BIOS_PRESENT, PCIBIOS_FIND_PCI_DEVICE, PCIBIOS_READ_CONFIG_BYTE, PCIBIOS_READ_CONFIG_WORD и т.п., которые необходимо вызвать Подскажите пожалуйста, Как повторить нижний пример на асемблере под Win32? Спасибо, Игорь. Пример из Линукса, который это делает: Code (Text): static struct { unsigned long address; unsigned short segment; } pci_indirect = { 0, KERNEL_CS }; static int pci_bios_find_device(unsigned short vendor, unsigned short device_id, unsigned short index, unsigned char *bus, unsigned char *device_fn) { unsigned short bx; unsigned short ret; unsigned long flags; save_flags(flags); cli(); __asm__("lcall (%%edi)\n\t" "jc 1f\n\t" "xor %%ah, %%ah\n" "1:" : "=b" (bx), "=a" (ret) : "1" (PCIBIOS_FIND_PCI_DEVICE), "c" (device_id), "d" (vendor), "S" ((int) index), "D" (&pci_indirect)); restore_flags(flags); *bus = (bx >> 8) & 0xff; *device_fn = bx & 0xff; return (int) (ret & 0xff00) >> 8; } Кроме того, есть след описание для данного вызова: The BIOS32 Service Directory is accessed by doing a CALL FAR to the entry point provided in the Service data structure. This function returns the location of PCI devices that have a specific Class Code. Given a Class Code and a Index (N), the function returns the Bus Number, Device Number, and Function Number of the Nth Device/Function whose Class Code matches the input parameters. ENTRY: [AH] PCI_FUNCTION_ID [AL] FIND_PCI_CLASS_CODE [ECX] Class Code (in lower three bytes) [SI] Index (0...N) EXIT: [BH] Bus Number (0...255) [BL] Device Number in upper 5 bits, Function Number in bottom 3 bits [AH] Return Code: SUCCESSFUL, DEVICE_NOT_FOUND [CF] Completion Status, set = error, cleared = success. Calling software can find all devices having the same Class Code by making successive calls to this function starting with Index set to zero, and incrementing it until the return code is ’DEVICE_NOT_FOUND’. PS. Найденный сервисный адрес - "физический" я его предварительно отмапил на виртуальное пространство с помощью MmMapIoSpace
HAL используется но не всегда помогает . PCI-to-PCI brige не могут быть перепрограммированы HAL функциями: A call to HalSetBusData or HalSetBusDataByOffset fails if the target device is a PCI bridge device and the data to be written is within the PCI common configuration space header. This behavior is by-design, because these functions are used only for programming nonbridge devices. То что не работает уже проверено, PCI bios спасенье
Code (Text): static struct { unsigned long address; unsigned short segment; } pci_indirect = { 0, KERNEL_CS }; static int pci_bios_find_device(unsigned short vendor, unsigned short device_id, unsigned short index, unsigned char *bus, unsigned char *device_fn) { unsigned short __bx; unsigned short ret; unsigned long flags; void *__pci_indirect = &pci_indirect; asm { pushfd cli mov eax, PCIBIOS_FIND_PCI_DEVICE mov ecx, device_id mov edx, vendor mov esi, index mov edi, __pci_indirect call far dword ptr [edi] jc short $ + 2 xor ah, ah mov ret, eax mov __bx, ebx popfd } *bus = (__bx >> 8) & 0xff; *device_fn = __bx & 0xff; return (int) (ret & 0xff00) >> 8; }