diff options
author | Megan Wachs <megan@sifive.com> | 2016-07-20 23:59:02 +0000 |
---|---|---|
committer | Megan Wachs <megan@sifive.com> | 2016-07-26 08:40:12 -0700 |
commit | 2887165ae2990e7f93038f3220ed74ee429b5244 (patch) | |
tree | 13c4cb83e47d6ab390e0465e883acf0973611e8e /bootrom/common | |
parent | a2d28c8318ab3ed40b3674aeee8b9487a3129f15 (diff) |
Initial Checkin
Diffstat (limited to 'bootrom/common')
-rw-r--r-- | bootrom/common/bram.ld | 40 | ||||
-rw-r--r-- | bootrom/common/mem.awk | 63 |
2 files changed, 103 insertions, 0 deletions
diff --git a/bootrom/common/bram.ld b/bootrom/common/bram.ld new file mode 100644 index 0000000..45df67f --- /dev/null +++ b/bootrom/common/bram.ld @@ -0,0 +1,40 @@ +OUTPUT_ARCH("riscv") +ENTRY(_start) + +MEMORY +{ + rom (rx) : ORIGIN = 0x00001000, LENGTH = 4K + ram (rwx) : ORIGIN = 0x80000000, LENGTH = 256M +} + +SECTIONS +{ + PROVIDE(_rom = ORIGIN(rom)); + PROVIDE(_rom_end = _rom + LENGTH(rom)); + PROVIDE(_ram = ORIGIN(ram)); + PROVIDE(_ram_end = _ram + LENGTH(ram)); + + .text : { + PROVIDE(_ftext = .); + *(.text.init) + *(.text .text.* .gnu.linkonce.t.*) + PROVIDE(_etext = .); + } > rom + + .rodata : { + *(.rodata .rodata.* .gnu.linkonce.r.*) + } > rom + + .bss : ALIGN(8) { + PROVIDE(_fbss = .); + *(.bss .bss.* .gnu.linkonce.b.*) + *(.sbss .sbss.* .gnu.linkonce.sb.*) + . = ALIGN(8); + PROVIDE(_ebss = .); + } > ram + + . += 0x1000; + PROVIDE(_sp = NEXT(0x1000)); + + PROVIDE(_end = .); +} diff --git a/bootrom/common/mem.awk b/bootrom/common/mem.awk new file mode 100644 index 0000000..3003b56 --- /dev/null +++ b/bootrom/common/mem.awk @@ -0,0 +1,63 @@ +BEGIN { + RS = ORS = "\r\n" + addr = 0 + buf = "" + limit = (WIDTH > 0 ? WIDTH / 4 : 16) + print "@00000000" +} + +# Portable strtonum() replacement +function atoi(str, x, n, i, b, c) { + if (str ~ /^0[0-7]*$/) { + i = 2 + b = 8 + } else if (str ~ /^0[xX][[:xdigit:]]+$/) { + i = 3 + b = 16 + } else { + return str + } + + x = 0 + n = length(str) + for (; i <= n; i++) { + c = tolower(substr(str, i , 1)) + c = index("123456789abcdef", c) + x = (x * b) + c + } + return x +} + +function out(x) { + addr++ + buf = (REVERSE ? buf x : x buf) + if (length(buf) >= limit) { + print buf + buf = "" + } +} + +function pad(n) { + while (addr < n) { + out("00") + } +} + +match($1, /^@[[:xdigit:]]+/) { + pad(atoi("0x" substr($1, RSTART+1, RLENGTH-1))) + next +} + +{ + for (i = 1; i <= NF; i++) { + out($i) + } +} + +END { + align = limit / 2 + pad(int((addr + align - 1) / align) * align) + if (length(buf) > 0) { + print buf; + } +} |