FreeCalypso > hg > freecalypso-sw
changeset 992:a7b0b426f9ca
target-utils: boot ROM UART autodetection revamped
The new implementation should work with both the familiar Calypso C035
boot ROM version found in our regular targets as well as the older
Calypso F741979B version found on the vintage D-Sample board.
author | Mychaela Falconia <falcon@ivan.Harhan.ORG> |
---|---|
date | Wed, 30 Dec 2015 21:28:41 +0000 |
parents | 5cff3579814c |
children | d92e4aadeeb3 |
files | target-utils/env/iram.lds target-utils/helloapp/main.c target-utils/include/halt.h target-utils/libbase/serio.S target-utils/libcommon/uartsel.c target-utils/loadagent/main.c target-utils/pirexplore/main.c |
diffstat | 7 files changed, 33 insertions(+), 39 deletions(-) [+] |
line wrap: on
line diff
--- a/target-utils/env/iram.lds Wed Dec 30 20:48:12 2015 +0000 +++ b/target-utils/env/iram.lds Wed Dec 30 21:28:41 2015 +0000 @@ -39,10 +39,6 @@ PROVIDE(end = .); } -/* a few absolute definitions */ -rom_vars = 0x800518; -/* stack_bottom = 0x83FFFC; */ - /* * stack_bottom will be set via the --defsym option to ld. * Some programs have minimal IRAM requirements, so it would make more
--- a/target-utils/helloapp/main.c Wed Dec 30 20:48:12 2015 +0000 +++ b/target-utils/helloapp/main.c Wed Dec 30 21:28:41 2015 +0000 @@ -1,18 +1,8 @@ -#include "types.h" -#include "romvars.h" - -extern struct boot_rom_vars rom_vars; - -extern char *uart_name; - main() { uart_select_init(); printf("Hello-world demo app running\n"); - printf("Loaded via UART %d (%s) at baud rate #%d\n", rom_vars.uart_id, - uart_name, rom_vars.baud_rate_code); - printf("TCXO clock input autodetected to be %d MHz\n", - rom_vars.clktcxo_13mhz ? 13 : 26); + print_boot_rom_info(); for (;;) { putchar('='); if (command_entry())
--- a/target-utils/include/halt.h Wed Dec 30 20:48:12 2015 +0000 +++ b/target-utils/include/halt.h Wed Dec 30 21:28:41 2015 +0000 @@ -8,3 +8,4 @@ #define HALTCODE_MAINEXITED 0x40 #define HALTCODE_INVALIDUART 0x41 +#define HALTCODE_BOOTROMVER 0x42
--- a/target-utils/libbase/serio.S Wed Dec 30 20:48:12 2015 +0000 +++ b/target-utils/libbase/serio.S Wed Dec 30 21:28:41 2015 +0000 @@ -2,6 +2,8 @@ @ this module implements the elementary serial I/O operations + .comm uart_base,4,4 + .text .code 32 .global serial_out
--- a/target-utils/libcommon/uartsel.c Wed Dec 30 20:48:12 2015 +0000 +++ b/target-utils/libcommon/uartsel.c Wed Dec 30 21:28:41 2015 +0000 @@ -9,14 +9,28 @@ #include "ns16550.h" #include "halt.h" -extern struct boot_rom_vars rom_vars; +extern struct ns16550_regs *uart_base; -struct ns16550_regs *uart_base; -char *uart_name; +static u16 rom_version; +static struct boot_rom_vars *rom_vars; +static char *uart_name; uart_select_init() { - switch (rom_vars.uart_id) { + rom_version = *(u16 *)0x1FFE; + + switch (rom_version) { + case 0x0200: + rom_vars = (struct boot_rom_vars *) 0x800504; + break; + case 0x0300: + rom_vars = (struct boot_rom_vars *) 0x800518; + break; + default: + _exit(HALTCODE_BOOTROMVER); + } + + switch (rom_vars->uart_id) { case 0: uart_base = (struct ns16550_regs *) 0xFFFF5800; uart_name = "MODEM"; @@ -29,3 +43,12 @@ _exit(HALTCODE_INVALIDUART); } } + +print_boot_rom_info() +{ + printf("Loaded via boot ROM v%04X, UART %d (%s) at baud rate #%d\n", + rom_version, rom_vars->uart_id, uart_name, + rom_vars->baud_rate_code); + printf("CLKTCXO input autodetected to be %d MHz\n", + rom_vars->clktcxo_13mhz ? 13 : 26); +}
--- a/target-utils/loadagent/main.c Wed Dec 30 20:48:12 2015 +0000 +++ b/target-utils/loadagent/main.c Wed Dec 30 21:28:41 2015 +0000 @@ -2,21 +2,11 @@ * FreeCalypso loadagent main() function lives here */ -#include "types.h" -#include "romvars.h" - -extern struct boot_rom_vars rom_vars; - -extern char *uart_name; - main() { uart_select_init(); printf("FreeCalypso loadagent running\n"); - printf("Loaded via UART %d (%s) at baud rate #%d\n", rom_vars.uart_id, - uart_name, rom_vars.baud_rate_code); - printf("TCXO clock input autodetected to be %d MHz\n", - rom_vars.clktcxo_13mhz ? 13 : 26); + print_boot_rom_info(); for (;;) { putchar('='); if (command_entry())
--- a/target-utils/pirexplore/main.c Wed Dec 30 20:48:12 2015 +0000 +++ b/target-utils/pirexplore/main.c Wed Dec 30 21:28:41 2015 +0000 @@ -1,18 +1,10 @@ #include "types.h" -#include "romvars.h" - -extern struct boot_rom_vars rom_vars; - -extern char *uart_name; main() { uart_select_init(); printf("Pirelli hardware exploration utility running\n"); - printf("Loaded via UART %d (%s) at baud rate #%d\n", rom_vars.uart_id, - uart_name, rom_vars.baud_rate_code); - printf("TCXO clock input autodetected to be %d MHz\n", - rom_vars.clktcxo_13mhz ? 13 : 26); + print_boot_rom_info(); /* * Make the same register settings as in the init script used by * fc-loadtool and fc-xram: ../../loadtools/scripts/pirelli.init