Simple question about ROM

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
devsau
Member
Member
Posts: 35
Joined: Thu Jun 13, 2013 12:07 pm

Simple question about ROM

Post by devsau »

My interpretation is that ROM 'listens' on the address bus like RAM or any other device. However what happens when an instruction, say from my bootloader code, tries to write to an area located within ROM. Does the instruction cycles for that instruction complete, but nothing is actually written? Is a machine check generated?

Thanks
User avatar
iansjack
Member
Member
Posts: 4711
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Simple question about ROM

Post by iansjack »

Why not just try it and see what happens?
Nable
Member
Member
Posts: 453
Joined: Tue Nov 08, 2011 11:35 am

Re: Simple question about ROM

Post by Nable »

It's too chipset-specific.
On rather modern PCs you don't have direct access to ROM. There's some slow read access for early boot stage when BIOS image is unpacked to RAM and then you're working with RAM only (+ some chipset-specific access via some 'firmware hub' part).
If you can address ROM directly then it depends on how it's wired: may be WE# (write enable) line is not connected to memory chip at all (so nothing happens); may be we have some kind of EEPROM, they (parallel ones, not SPI-programmable) usually interpet write access as a command (you can find exact information in datasheets), so you can easily screw things up.

I can also recommend you to study source code of Uniflash or flashrom (sorry, i don't have exact link right now but you can start from http://flashrom.org/Uniflash).
devsau
Member
Member
Posts: 35
Joined: Thu Jun 13, 2013 12:07 pm

Re: Simple question about ROM

Post by devsau »

iansjack wrote:Why not just try it and see what happens?

I have, but only in emulated environments. As expected, the instruction cycles finish without any interrupt but the write is not reflected. I just didn't assume that in this case that the emulated environment could account for a real machine. I don't know what to expect in this case.
devsau
Member
Member
Posts: 35
Joined: Thu Jun 13, 2013 12:07 pm

Re: Simple question about ROM

Post by devsau »

Nable wrote:It's too chipset-specific.
On rather modern PCs you don't have direct access to ROM. There's some slow read access for early boot stage when BIOS image is unpacked to RAM and then you're working with RAM only (+ some chipset-specific access via some 'firmware hub' part).
If you can address ROM directly then it depends on how it's wired: may be WE# (write enable) line is not connected to memory chip at all (so nothing happens); may be we have some kind of EEPROM, they (parallel ones, not SPI-programmable) usually interpet write access as a command (you can find exact information in datasheets), so you can easily screw things up.

I can also recommend you to study source code of Uniflash or flashrom (sorry, i don't have exact link right now but you can start from http://flashrom.org/Uniflash).

cool. thank you for the link :D
Post Reply