- Aug 12, 2014
- 522
- 3
- 81
Hello everyone,
OK, so I have a decent idea of how peripherals are linked and how the CPU sees and communicates with them.
The BIOS firmware is responsible for assigning addresses to peripherals at boot time by writing to the peripherals' base address registers. The option ROMs are assigned addresses as well.
The CPU uses memory mapped I/O to send data to the peripherals by sending addresses to the memory controller just as if the CPU were trying to reach RAM locations. I may be wrong, but I don't think that isolated I/O is used anymore.
OK, so here's my question:
Let's say you write a program, and the program tells the CPU to read from a memory location on a peripheral device and do something with it.
Well, the BIOS has assigned that peripheral device, specifically the memory location on that peripheral device, a memory address mapped into the CPU's address space.
So, when you compile and link your source code, the machine instruction that's generated for that read instruction should just be a simple mov instruction that contains the address of the peripheral's memory location.
But, doesn't the BIOS assign those addresses differently after every boot?
If after the current the boot, peripheral memory location #3 has address 10 but after the next boot, the same peripheral memory location has address 15, how can the same code work successfully from boot to boot?
Thanks.
OK, so I have a decent idea of how peripherals are linked and how the CPU sees and communicates with them.
The BIOS firmware is responsible for assigning addresses to peripherals at boot time by writing to the peripherals' base address registers. The option ROMs are assigned addresses as well.
The CPU uses memory mapped I/O to send data to the peripherals by sending addresses to the memory controller just as if the CPU were trying to reach RAM locations. I may be wrong, but I don't think that isolated I/O is used anymore.
OK, so here's my question:
Let's say you write a program, and the program tells the CPU to read from a memory location on a peripheral device and do something with it.
Well, the BIOS has assigned that peripheral device, specifically the memory location on that peripheral device, a memory address mapped into the CPU's address space.
So, when you compile and link your source code, the machine instruction that's generated for that read instruction should just be a simple mov instruction that contains the address of the peripheral's memory location.
But, doesn't the BIOS assign those addresses differently after every boot?
If after the current the boot, peripheral memory location #3 has address 10 but after the next boot, the same peripheral memory location has address 15, how can the same code work successfully from boot to boot?
Thanks.