mirror of
https://github.com/enjoy-digital/litex.git
synced 2025-01-04 09:52:26 -05:00
software: allow BIOS compilation with UART disabled.
This commit is contained in:
parent
19fda3364a
commit
1ce194007b
6 changed files with 52 additions and 9 deletions
|
@ -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 */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -49,7 +49,10 @@
|
|||
|
||||
static void boot_sequence(void)
|
||||
{
|
||||
if(serialboot()) {
|
||||
#ifdef CSR_UART_BASE
|
||||
if (serialboot() == 0)
|
||||
return;
|
||||
#endif
|
||||
#ifdef FLASH_BOOT_ADDRESS
|
||||
flashboot();
|
||||
#endif
|
||||
|
@ -70,7 +73,6 @@ static void boot_sequence(void)
|
|||
#endif
|
||||
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");
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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
|
Loading…
Reference in a new issue