software: allow BIOS compilation with UART disabled.

This commit is contained in:
Florent Kermarrec 2021-01-08 19:18:44 +01:00
parent 19fda3364a
commit 1ce194007b
6 changed files with 52 additions and 9 deletions

View file

@ -100,6 +100,8 @@ void romboot(void)
/* Serial Boot */
/*-----------------------------------------------------------------------*/
#ifdef CSR_UART_BASE
static int check_ack(void)
{
int recognized;
@ -265,6 +267,8 @@ int serialboot(void)
return 1;
}
#endif
/*-----------------------------------------------------------------------*/
/* Ethernet Boot */
/*-----------------------------------------------------------------------*/

View file

@ -50,7 +50,9 @@ define_command(romboot, romboot, "Boot from ROM", BOOT_CMDS);
* Boot software from serial interface
*
*/
#ifdef CSR_UART_BASE
define_command(serialboot, serialboot, "Boot from Serial (SFL)", BOOT_CMDS);
#endif
/**
* Command "netboot"

View file

@ -151,10 +151,12 @@ void isr(void)
irqs = irq_pending() & irq_getmask();
#ifdef CSR_UART_BASE
#ifndef UART_POLLING
if(irqs & (1 << UART_INTERRUPT))
uart_isr();
#endif
#endif
}
#endif

View file

@ -49,27 +49,29 @@
static void boot_sequence(void)
{
if(serialboot()) {
#ifdef CSR_UART_BASE
if (serialboot() == 0)
return;
#endif
#ifdef FLASH_BOOT_ADDRESS
flashboot();
flashboot();
#endif
#ifdef ROM_BOOT_ADDRESS
romboot();
romboot();
#endif
#if defined(CSR_SPISDCARD_BASE) || defined(CSR_SDCORE_BASE)
sdcardboot();
sdcardboot();
#endif
#if defined(CSR_SATA_SECTOR2MEM_BASE)
sataboot();
sataboot();
#endif
#ifdef CSR_ETHMAC_BASE
#ifdef CSR_ETHPHY_MODE_DETECTION_MODE_ADDR
eth_mode();
eth_mode();
#endif
netboot();
netboot();
#endif
printf("No boot medium found\n");
}
printf("No boot medium found\n");
}
int main(int i, char **c)
@ -85,7 +87,9 @@ int main(int i, char **c)
irq_setmask(0);
irq_setie(1);
#endif
#ifdef CSR_UART_BASE
uart_init();
#endif
printf("\n");
printf("\e[1m __ _ __ _ __\e[0m\n");

View file

@ -3,6 +3,8 @@
#include <stdio.h>
#include <stdarg.h>
#include <generated/csr.h>
FILE *stdin, *stdout, *stderr;
static console_write_hook write_hook;
@ -20,6 +22,7 @@ void console_set_read_hook(console_read_hook r, console_read_nonblock_hook rn)
read_nonblock_hook = rn;
}
#ifdef CSR_UART_BASE
int putchar(int c)
{
uart_write(c);
@ -46,6 +49,30 @@ int readchar_nonblock(void)
|| ((read_nonblock_hook != NULL) && read_nonblock_hook()));
}
#else
int putchar(int c)
{
if(write_hook != NULL)
write_hook(c);
return c;
}
char readchar(void)
{
while(1) {
if((read_nonblock_hook != NULL) && read_nonblock_hook())
return read_hook();
}
}
int readchar_nonblock(void)
{
return ((read_nonblock_hook != NULL) && read_nonblock_hook());
}
#endif
int puts(const char *s)
{
while(*s) {

View file

@ -2,6 +2,8 @@
#include <irq.h>
#include <generated/csr.h>
#ifdef CSR_UART_BASE
/*
* Buffer sizes must be a power of 2 so that modulos can be computed
* with logical AND.
@ -151,3 +153,5 @@ void uart_sync(void)
}
#endif
#endif