Skip to content

Commit

Permalink
software: allow BIOS compilation with UART disabled.
Browse files Browse the repository at this point in the history
  • Loading branch information
enjoy-digital committed Jan 8, 2021
1 parent 19fda33 commit 1ce1940
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 9 deletions.
4 changes: 4 additions & 0 deletions litex/soc/software/bios/boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ void romboot(void)
/* Serial Boot */
/*-----------------------------------------------------------------------*/

#ifdef CSR_UART_BASE

static int check_ack(void)
{
int recognized;
Expand Down Expand Up @@ -265,6 +267,8 @@ int serialboot(void)
return 1;
}

#endif

/*-----------------------------------------------------------------------*/
/* Ethernet Boot */
/*-----------------------------------------------------------------------*/
Expand Down
2 changes: 2 additions & 0 deletions litex/soc/software/bios/cmds/cmd_boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions litex/soc/software/bios/isr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
22 changes: 13 additions & 9 deletions litex/soc/software/bios/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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");
Expand Down
27 changes: 27 additions & 0 deletions litex/soc/software/libbase/console.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include <stdio.h>
#include <stdarg.h>

#include <generated/csr.h>

FILE *stdin, *stdout, *stderr;

static console_write_hook write_hook;
Expand All @@ -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);
Expand All @@ -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) {
Expand Down
4 changes: 4 additions & 0 deletions litex/soc/software/libbase/uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -150,4 +152,6 @@ void uart_sync(void)
while (uart_txfull_read());
}

#endif

#endif

0 comments on commit 1ce1940

Please sign in to comment.