pl011 uart: Work around Rpi constructors not getting called
* Serial UART output on Raspberry Pi now functioning This is kind of a hack, however having serial output will enable easier debugging of loader. Not a perimant fix. * With UART output, we can now turn to why the constructors are so messed up. * Thanks to pfoetchen for his help and (lots!) of testing.
This commit is contained in:
@@ -21,8 +21,6 @@ UartPL011 gLoaderUART(uart_base_debug());
|
|||||||
|
|
||||||
|
|
||||||
static int32 sSerialEnabled = 0;
|
static int32 sSerialEnabled = 0;
|
||||||
static char sBuffer[16384];
|
|
||||||
static uint32 sBufferPosition;
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -38,12 +36,7 @@ serial_puts(const char* string, size_t size)
|
|||||||
if (sSerialEnabled <= 0)
|
if (sSerialEnabled <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (sBufferPosition + size < sizeof(sBuffer)) {
|
while (size-- > 0) {
|
||||||
memcpy(sBuffer + sBufferPosition, string, size);
|
|
||||||
sBufferPosition += size;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (size-- != 0) {
|
|
||||||
char c = string[0];
|
char c = string[0];
|
||||||
|
|
||||||
if (c == '\n') {
|
if (c == '\n') {
|
||||||
@@ -86,7 +79,5 @@ serial_init(void)
|
|||||||
|
|
||||||
serial_enable();
|
serial_enable();
|
||||||
|
|
||||||
serial_putc('!');
|
serial_puts("Serial startup\n", 15);
|
||||||
serial_puts("SER INIT", 8);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ clear_bss(void)
|
|||||||
static void
|
static void
|
||||||
call_ctors(void)
|
call_ctors(void)
|
||||||
{
|
{
|
||||||
|
#warning BUG: constructors don't get called!
|
||||||
void (**f)(void);
|
void (**f)(void);
|
||||||
|
|
||||||
for (f = &__ctor_list; f < &__ctor_end; f++) {
|
for (f = &__ctor_list; f < &__ctor_end; f++) {
|
||||||
@@ -65,7 +66,7 @@ abort(void)
|
|||||||
uint32
|
uint32
|
||||||
platform_boot_options(void)
|
platform_boot_options(void)
|
||||||
{
|
{
|
||||||
#warning IMPLEMENT platform_boot_options
|
#warning IMPLEMENT platform_boot_options
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,7 +74,7 @@ platform_boot_options(void)
|
|||||||
void
|
void
|
||||||
platform_start_kernel(void)
|
platform_start_kernel(void)
|
||||||
{
|
{
|
||||||
#warning IMPLEMENT platform_start_kernel
|
#warning IMPLEMENT platform_start_kernel
|
||||||
panic("kernel returned!\n");
|
panic("kernel returned!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,7 +82,7 @@ platform_start_kernel(void)
|
|||||||
void
|
void
|
||||||
platform_exit(void)
|
platform_exit(void)
|
||||||
{
|
{
|
||||||
#warning IMPLEMENT platform_exit
|
#warning IMPLEMENT platform_exit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -104,7 +104,9 @@ void
|
|||||||
UartPL011::InitEarly()
|
UartPL011::InitEarly()
|
||||||
{
|
{
|
||||||
// Perform special hardware UART configuration
|
// Perform special hardware UART configuration
|
||||||
// Raspberry Pi: Early gpio handled by gpio_init in platform code
|
|
||||||
|
#warning Raspberry Pi Hack: Fix constructors not getting called in loader.
|
||||||
|
fUARTBase = uart_base_debug();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -135,7 +137,7 @@ int
|
|||||||
UartPL011::PutChar(char c)
|
UartPL011::PutChar(char c)
|
||||||
{
|
{
|
||||||
if (fUARTEnabled == true) {
|
if (fUARTEnabled == true) {
|
||||||
WriteUart(PL01x_DR, (unsigned int)c);
|
WriteUart(PL01x_DR, c);
|
||||||
// Empty the transmit buffer
|
// Empty the transmit buffer
|
||||||
FlushTx();
|
FlushTx();
|
||||||
return 0;
|
return 0;
|
||||||
@@ -145,7 +147,6 @@ UartPL011::PutChar(char c)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* returns -1 if no data available */
|
|
||||||
int
|
int
|
||||||
UartPL011::GetChar(bool wait)
|
UartPL011::GetChar(bool wait)
|
||||||
{
|
{
|
||||||
@@ -158,7 +159,6 @@ void
|
|||||||
UartPL011::FlushTx()
|
UartPL011::FlushTx()
|
||||||
{
|
{
|
||||||
while (ReadUart(PL01x_FR) & PL01x_FR_TXFF);
|
while (ReadUart(PL01x_FR) & PL01x_FR_TXFF);
|
||||||
// wait for the last char to get out
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user