3 ms·
Coreboot does something similar to this. Very early in the boot process the RAM has not yet been initialized and so cannot be used. You need to execute some c
by abbeyj 6y ago
Coreboot does something similar to this. Very early in the boot process the RAM has not yet been initialized and so cannot be used. You need to execute some code to set up the RAM before you can use it. One approach to handling this is to write that initialization code in assembly language and make sure it only uses registers and doesn't touch any memory.
But that's inconvenient. You'd much rather be able to write your code in something like C. Any C code compiled by an ordinary compiler is going to access memory (at least for the stack). Writing and maintaining a custom C compiler for this is a lot of work and still comes with a lot of limitations on the C code that it will accept.
So they set up the cache in a way that it will never try to write its contents out to RAM. Then you can use the output of an ordinary C compiler that uses memory accesses and those accesses will all be served by the cache and never touch RAM. They call this "Cache as RAM".
With some work you could probably boot into DOS like this.
https://www.coreboot.org/data/yhlu/cache_as_ram_lb_09142006.pdf https://www.coreboot.org/data/yhlu/cache_as_ram_lb_09142006....
- als0 6y agoNot just coreboot, pretty much any BIOS uses cache-as-RAM.
- ahmedalsudani 6y agoWow that is so cool. Most of us never have to dig that deep and so weird stuff like that usually flies completely under the radar... Thank you for sharing!
- mcot2 6y agoInteresting that no one to my knowledge has built an architecture where sram is ‘memory’ such that it would be transparent to C code but no slower dram is used. 32MB is more than my 1998 computer had.
- jnwatson 6y agoMany embedded systems have a block of SRAM directly addressable.
- rijoja 6y agomodify tcc maybe
- jnwatson 6y agoThis is a common approach for most bootloaders, in fact for several microprocessors (the IBM 440 comes to mind), it is the only way to boot.
- myself248 6y agoIs there a way to mess with the cache or MMU and prevent it from _trying_ to write out to DRAM, and be able run a minimal system purely from cache with the DRAM slots completely empty?