~funderscoreblog cgit wikiget in touch

Here's how you can dump the bootROM.

   1 // SPDX-License-Identifier: CC0
   2 
   3 /*
   4  * The bootROM's memory address differs depending on the SoC.
   5  * Set SOC_GX/SOC_G12 depending on which SoC bootROM you'd like 
   6  * to dump, like so:
   7  * `#define SOC_GX 1` or `#define SOC_G12 1`
   8  */
   9 #define SOC_GX 1
  10 
  11 #ifdef SOC_GX /* GXBB/GXL */
  12 #define UART_BASE     0xc81004c0
  13 #define BOOTROM_START 0xd9040000
  14 #define BOOTROM_END   0xd907ffff
  15 
  16 #elif SOC_G12 /* G12A/G12B/SM1 */
  17 #define UART_BASE     0xff803000
  18 #define BOOTROM_START 0xffff0000
  19 #define BOOTROM_END   0xffffffff
  20 #endif
  21 
  22 #define UART_WFIFO   (UART_BASE + (0 << 2))
  23 #define UART_STATUS  (UART_BASE + (3 << 2))
  24 #define readl(a)     *(volatile unsigned int *)(a)
  25 #define writel(v, a) *(volatile unsigned int *)(a) = (v)
  26 
  27 void putc(char c)
  28 {
  29         while (readl(UART_STATUS) & (1 << 21))
  30                 ;
  31         writel(UART_WFIFO, c);
  32 }
  33 
  34 void puts(char *s)
  35 {
  36         while (*s)
  37                 putc(*s++);
  38 }
  39 
  40 void _start(void)
  41 {
  42         puts("*** DUMPING BOOTROM ***"); /* To be stripped along with bootROM output in the final dump */
  43         for (int i = BOOTROM_START; i <= BOOTROM_END; i++)
  44                 putc(readl(i)); /* Dump */
  45 }
  46 
  47 /* i'm sleepy now: TODO: finish */