I developed a driver (LINUX and Windows) and the Verilog Code for the PCI Card and everything is ok when running on LINUX.
In Windows I installed the driver and everything was ok about installation without any error code but
Why the OS write zeroes to base address register BAR0 (offset 0x10) and BAR1 (offset 0x14) after booting?
BAR at Offset 0x00000010 is an I/O address.
BAR at Offset 0x00000014 is a memory-mapped address.
The OS try to reserve the resources for the device.
This is a normal behavior of the OS when it detects a new device.
The resources are reserved so that they are not used by any other device.
The driver should be able to map the device's memory and I/O registers to these reserved resources. But at DriverEntry function the driver read these base address register and save their values in local variable. Then, the driver write '1's to these registers and read them back, invert these values and add 1 to determine the size for each one bar. And finally restore the saved value writing to these base address register. The problem is that OS write '0's after booting (saved values are '0'). As my PCI memory size for bar 0 and bar 1 is 1048576 bytes (values stored in PCI card are 0xFFF00001 for Bar1 (I/O address) and 0xFFF00000 for Bar0 (memory-mapped address) and OS write '0's to them and in the DriverEntry function 0x00000001 and 0x00000000 are read for bar 0 and bar 1 respectively. I expected any value from 0x00000000 to 0xFFF00000 range.
A Hex dump in Windows:
A log for debug in LINUX:
[ 356.169129] pcittl32io - << PCI Config Initialization Complete >>
[ 356.169130] pcittl32io - BAR1 LEN is 1048576 bytes in size
[ 356.169131] pcittl32io - BAR1 is mapped to 0xdc200000
[ 356.169132] pcittl32io - BAR1 END is 0xdc2fffff
[ 356.169133] pcittl32io - BAR1 is mapped to 0xdc200000
[ 356.169149] pcittl32io - pointer my_data->ptr_bar1 = 000000008b0960d3
[ 356.169153] pcittl32io - before write at 0x0 0xaa000000
[ 356.169156] pcittl32io - Read at 0x0 0xaa000000
[ 356.169159] pcittl32io - Read at 0x4 0xd15
A hex dump in LINUX:
ubuntu@ubuntu:~/Desktop/pcittlkiran$ lspci -xxx -s 04:00.0
04:00.0 System peripheral: Device 5105:0101 (rev 01)
00: 05 51 01 01 03 00 00 04 01 00 80 08 00 00 00 00
10: 01 00 30 dc 00 00 a0 df 00 00 00 00 00 00 00 00
20: 00 00 00 00 00 00 00 00 00 00 00 00 05 51 01 01
30: 00 00 00 00 00 00 00 00 00 00 00 00 ff 01 00 00
A log for debug in Windows:
Maia_Debug: Device Created
Maia_Debug: Symbolic Link Created
Maia_Debug: Driver Loaded
Maia_Debug: PCI Config Read
Maia_Debug: PCI Device Found - Vendor ID: 0x5105, Device ID: 0x101
Maia_Debug: Entering on ConfigurePCIDevice
Maia_Debug: busNumber 0x00000004
Maia_Debug: slotNumber 0x00000000
Maia_Debug: BusNumber = 0x00000004, SlotNumber = 0x00000000, Offset = 0x00000004, Length = 0x00000004
Maia_Debug: Status & Command: 0x04000000
Maia_Debug: Status & Command READ After Write 0x3: 0x04000003
Maia_Debug: BusNumber = 0x00000004, SlotNumber = 0x00000000, Offset = 0x00000008, Length = 0x00000004
Maia_Debug: Revision: 0x1
Maia_Debug: Class Code: 0x0
Maia_Debug: Class Code: 0x80
Maia_Debug: Class Code: 0x8
Maia_Debug: BusNumber = 0x00000004, SlotNumber = 0x00000000, Offset = 0x00000010, Length = 0x00000004
Maia_Debug: BAR at Offset 0x00000010 is an I/O address.
Maia_Debug: baseAddressBAR0 0x00000001
Maia_Debug: BusNumber = 0x00000004, SlotNumber = 0x00000000, Offset = 0x00000014, Length = 0x00000004
Maia_Debug: HalGetBusDataByOffset status=0x00000004
Maia_Debug: BAR at Offset 0x00000014 is a memory-mapped address.
Maia_Debug: baseAddressBAR1 0x00000000