raspberrypi_arm: Drop old Raspberry Pi 1 boot loader.

* We transitioned to u-boot quite some time ago
* We also are dropping < ARMv7 support
This commit is contained in:
Alexander von Gluck IV
2017-07-11 14:39:13 -05:00
parent d86b44dbf3
commit 0cc293cf32
24 changed files with 0 additions and 1374 deletions
@@ -1,39 +0,0 @@
/*
* Copyright 2003, Axel Dörfler, [email protected]. All rights reserved.
* Distributed under the terms of the MIT License.
* Copyright 2011-2012, Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef KERNEL_BOOT_PLATFORM_PI_ARCH_H
#define KERNEL_BOOT_PLATFORM_PI_ARCH_H
#include <SupportDefs.h>
struct kernel_args;
#ifdef __cplusplus
extern "C" {
#endif
/* memory management */
extern status_t arch_set_callback(void);
extern void *arch_mmu_allocate(void *address, size_t size, uint8 protection,
bool exactAddress);
extern status_t arch_mmu_free(void *address, size_t size);
extern status_t arch_mmu_init(void);
/* CPU */
extern status_t boot_arch_cpu_init(void);
/* kernel start */
status_t arch_start_kernel(struct kernel_args *kernelArgs, addr_t kernelEntry,
addr_t kernelStackTop);
#ifdef __cplusplus
}
#endif
#endif /* KERNEL_BOOT_PLATFORM_PI_ARCH_H */
@@ -1,45 +0,0 @@
/*
* Copyright 2012, Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _PLATFORM_DEBUG_H_
#define _PLATFORM_DEBUG_H_
#define DEBUG_DELAY_SHORT 200
#define DEBUG_DELAY_MEDIUM 500
#define DEBUG_DELAY_LONG 1000
void debug_delay(int time);
void debug_set_led(bool on);
void debug_toggle_led(int count, int delay = DEBUG_DELAY_MEDIUM);
// Toggles the led count times with the delay for both on and off time.
void debug_blink_number(int number);
// Implements a blink pattern to output arbitrary numbers:
//
// 1. Led turns off and stays off for a long delay.
// 2. Led blinks x times with a short delay, where x is the current
// decimal place + 1 (so 0 values are easier to see).
// 3. Led stays off for a long delay to indicate the move to the next
// decimal place and step 2. is repeated until all the rest of the
// number is 0.
// 4. The led turns on and stays on with a long delay to indicate finish.
// 5. Led state is reset to the original value.
//
// The lowest decimal is output first, so the number will be reversed. As an
// example the number 205 would be blinked as follows:
// long off (start indicator), 6 blinks (indicating 5),
// long off (moving to next decimal), 1 blink (indicating 0)
// long off (moving to next decimal), 3 blinks (indicating 2)
// long on (finish indicator)
void debug_halt();
// Stalls execution in an endless loop.
void debug_assert(bool condition);
// Flashes the led 20 times rapidly and stalls execution if the condition
// isn't met.
#endif // _PLATFORM_DEBUG_H_
@@ -1,24 +0,0 @@
/*
* Copyright 2009-2011, Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef KERNEL_BOOT_PLATFORM_PI_KERNEL_ARGS_H
#define KERNEL_BOOT_PLATFORM_PI_KERNEL_ARGS_H
#ifndef KERNEL_BOOT_KERNEL_ARGS_H
# error This file is included from <boot/kernel_args.h> only
#endif
#define SMP_MAX_CPUS 1
#define MAX_PHYSICAL_MEMORY_RANGE 4
#define MAX_PHYSICAL_ALLOCATED_RANGE 8
#define MAX_VIRTUAL_ALLOCATED_RANGE 32
typedef struct {
char dummy;
} platform_kernel_args;
#endif /* KERNEL_BOOT_PLATFORM_PI_KERNEL_ARGS_H */
@@ -1,17 +0,0 @@
/*
* Copyright 2009-2012, Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef KERNEL_BOOT_PLATFORM_PI_STAGE2_H
#define KERNEL_BOOT_PLATFORM_PI_STAGE2_H
#ifndef KERNEL_BOOT_STAGE2_ARGS_H
# error This file is included from <boot/stage2_args.h> only
#endif
struct platform_stage2_args {
void *boot_tgz_data;
uint32 boot_tgz_size;
};
#endif /* KERNEL_BOOT_PLATFORM_PI_STAGE2_H */
@@ -1,57 +0,0 @@
SubDir HAIKU_TOP src system boot platform raspberrypi_arm ;
SubDirHdrs $(HAIKU_TOP) headers private kernel boot platform $(TARGET_BOOT_PLATFORM) ;
SubDirHdrs $(HAIKU_TOP) src system boot arch $(TARGET_ARCH) ;
SubDirHdrs $(HAIKU_TOP) src system kernel debug ;
UsePrivateHeaders [ FDirName kernel disk_device_manager ] ;
UsePrivateHeaders [ FDirName graphics common ] ;
UsePrivateHeaders [ FDirName graphics vesa ] ;
UsePrivateHeaders [ FDirName storage ] ;
UsePrivateHeaders [ FDirName kernel arch $(TARGET_KERNEL_ARCH) board $(TARGET_BOOT_BOARD) ] ;
{
local defines = _BOOT_MODE
BOOT_ARCHIVE_BASE=$(HAIKU_BOARD_BOOT_ARCHIVE_BASE)
BOOT_ARCHIVE_SIZE=$(HAIKU_BOARD_BOOT_ARCHIVE_SIZE) ;
defines = [ FDefines $(defines) ] ;
SubDirCcFlags $(defines) ;
SubDirC++Flags $(defines) -fno-rtti ;
}
SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src add-ons accelerants common ] ;
BootMergeObject boot_platform_raspberrypi_arm.o :
entry.S
start.cpp
console.cpp
cpu.cpp
debug.cpp
devices.cpp
gpio.cpp
keyboard.cpp
mailbox.cpp
menu.cpp
serial.cpp
video.cpp
arch_framebuffer_bcm2835.cpp
$(genericPlatformSources)
:
: boot_platform_generic.a
;
SEARCH on [ FGristFiles $(genericPlatformSources) ]
= [ FDirName $(HAIKU_TOP) src system boot platform generic ] ;
SEARCH on [ FGristFiles devices.cpp ]
= [ FDirName $(HAIKU_TOP) src system boot platform u-boot ] ;
# Tell the build system to where stage1.bin can be found, so it can be used
# elsewhere.
SEARCH on stage1.bin = $(SUBDIR) ;
@@ -1,3 +0,0 @@
THIS PLATFORM CODE SHOULD DIE SOON IN FAVOR OF U-BOOT
Any early ARM drivers should move over to src/system/boot/arch/arm
-- Alex v. 2015
@@ -1,37 +0,0 @@
/*
* Copyright 2011, Fran??ois Revol <revol@free.fr>.
* All rights reserved. Distributed under the terms of the MIT License.
*/
#include <arch/arm/arch_cpu.h>
#include <asm_defs.h>
.text
/*
* status_t arch_start_kernel(struct kernel_args *kernelArgs,
* addr_t kernelEntry, addr_t kernelStackTop);
r0 - kernelArgs
r1 - kernelEntry
r2 - kernelStackTop
*/
FUNCTION(arch_start_kernel):
// set the kernel stack
mov sp,r2
// set up kernel _start args
//mov r0,r0 // kernelArgs
mov r4,r1
mov r1,#0 // currentCPU=0
// call the kernel
mov pc,r4
// return
mov r0,#-1 // B_ERROR
mov pc,lr
FUNCTION_END(arch_start_kernel)
@@ -1,232 +0,0 @@
/*
* Copyright 2004-2005, Axel D?rfler, [email protected].
* All rights reserved. Distributed under the terms of the MIT License.
*
* Copyright 2009 Jonas Sundström, [email protected]
* All rights reserved. Distributed under the terms of the MIT License.
*/
#include "console.h"
#include "keyboard.h"
#include "serial.h"
#include <SupportDefs.h>
#include <util/kernel_cpp.h>
#include <boot/stage2.h>
#include <string.h>
class Console : public ConsoleNode {
public:
Console();
virtual ssize_t ReadAt(void* cookie, off_t pos, void* buffer,
size_t bufferSize);
virtual ssize_t WriteAt(void* cookie, off_t pos,
const void* buffer, size_t bufferSize);
};
class VTConsole : public ConsoleNode {
public:
VTConsole();
void ClearScreen();
void SetCursor(int32 x, int32 y);
void SetColor(int32 foreground, int32 background);
};
class SerialConsole : public VTConsole {
public:
SerialConsole();
virtual ssize_t ReadAt(void *cookie, off_t pos, void *buffer,
size_t bufferSize);
virtual ssize_t WriteAt(void *cookie, off_t pos, const void *buffer,
size_t bufferSize);
};
static Console sInput;
static Console sOutput;
static SerialConsole sSerial;
FILE* stdin;
FILE* stdout;
FILE* stderr;
// #pragma mark -
Console::Console()
:
ConsoleNode()
{
}
ssize_t
Console::ReadAt(void* cookie, off_t pos, void* buffer, size_t bufferSize)
{
// don't seek in character devices
// not implemented (and not yet? needed)
return B_ERROR;
}
ssize_t
Console::WriteAt(void* cookie, off_t /*pos*/, const void* buffer,
size_t bufferSize)
{
return 0;
}
// #pragma mark -
VTConsole::VTConsole()
:
ConsoleNode()
{
}
void
VTConsole::ClearScreen()
{
WriteAt(NULL, 0LL, "\033[2J", 4);
}
void
VTConsole::SetCursor(int32 x, int32 y)
{
char buffer[9];
x = MIN(80, MAX(1, x));
y = MIN(25, MAX(1, y));
int len = snprintf(buffer, sizeof(buffer),
"\033[%" B_PRId32 ";%" B_PRId32 "H", y, x);
WriteAt(NULL, 0LL, buffer, len);
}
void
VTConsole::SetColor(int32 foreground, int32 background)
{
static const char cmap[] = {
0, 4, 2, 6, 1, 5, 3, 7 };
char buffer[12];
if (foreground < 0 || foreground >= 8)
return;
if (background < 0 || background >= 8)
return;
// We assume normal display attributes here
int len = snprintf(buffer, sizeof(buffer),
"\033[%" B_PRId32 ";%" B_PRId32 "m",
cmap[foreground] + 30, cmap[background] + 40);
WriteAt(NULL, 0LL, buffer, len);
}
// #pragma mark -
SerialConsole::SerialConsole()
: VTConsole()
{
}
ssize_t
SerialConsole::ReadAt(void *cookie, off_t pos, void *buffer, size_t bufferSize)
{
// don't seek in character devices
// not implemented (and not yet? needed)
return B_ERROR;
}
ssize_t
SerialConsole::WriteAt(void *cookie, off_t /*pos*/, const void *buffer,
size_t bufferSize)
{
serial_puts((const char *)buffer, bufferSize);
return bufferSize;
}
// #pragma mark -
void
console_clear_screen(void)
{
sSerial.ClearScreen();
}
int32
console_width(void)
{
return 80;
}
int32
console_height(void)
{
return 25;
}
void
console_set_cursor(int32 x, int32 y)
{
sSerial.SetCursor(x, y);
}
void
console_show_cursor(void)
{
}
void
console_hide_cursor(void)
{
}
int
console_wait_for_key(void)
{
union key key;
key.ax = serial_getc(true);
return key.code.ascii;
}
void
console_set_color(int32 foreground, int32 background)
{
sSerial.SetColor(foreground, background);
}
status_t
console_init(void)
{
stdin = (FILE *)&sSerial;
stdout = (FILE *)&sSerial;
stderr = (FILE *)&sSerial;
return B_OK;
}
@@ -1,20 +0,0 @@
/*
* Copyright 2009 Jonas Sundström, [email protected]
* All rights reserved. Distributed under the terms of the MIT License.
*/
#ifndef _SYSTEM_BOOT_PLATFORM_STUB_CONSOLE_H
#define _SYSTEM_BOOT_PLATFORM_STUB_CONSOLE_H
#include <boot/platform/generic/text_console.h>
#ifdef __cplusplus
extern "C" {
#endif
extern status_t console_init(void);
#ifdef __cplusplus
}
#endif
#endif /* _SYSTEM_BOOT_PLATFORM_STUB_CONSOLE_H */
@@ -1,21 +0,0 @@
/*
* Copyright 2009 Jonas Sundström, [email protected]
* All rights reserved. Distributed under the terms of the MIT License.
*/
#include "arch_cpu.h"
extern "C" void
spin(bigtime_t microseconds)
{
// fallback to arch-specific code
arch_spin(microseconds);
}
extern "C" void
cpu_init()
{
boot_arch_cpu_init();
}
@@ -1,23 +0,0 @@
/*
* Copyright 2009 Jonas Sundström, [email protected]
* All rights reserved. Distributed under the terms of the MIT License.
*/
#ifndef _SYSTEM_BOOT_PLATFORM_PI_CPU_H
#define _SYSTEM_BOOT_PLATFORM_PI_CPU_H
#include <SupportDefs.h>
#ifdef __cplusplus
extern "C" {
#endif
extern void cpu_init(void);
#ifdef __cplusplus
}
#endif
#endif /* _SYSTEM_BOOT_PLATFORM_ROUTERBOARD_MIPSEL_CPU_H */
@@ -1,150 +0,0 @@
/*
* Copyright 2004-2005, Axel Dörfler, [email protected].
* All rights reserved. Distributed under the terms of the MIT License.
*
* Copyright 2009 Jonas Sundström, [email protected]
* All rights reserved. Distributed under the terms of the MIT License.
*/
#include "platform_debug.h"
#include "gpio.h"
#include "serial.h"
#include <boot/platform.h>
#include <boot/stdio.h>
#include <stdarg.h>
extern "C" void platform_video_puts(const char* string);
extern addr_t gPeripheralBase;
static bool sLedState = true;
void
debug_delay(int time)
{
for (; time >= 0; time--)
for (int i = 0; i < 10000; i++)
asm volatile ("nop");
}
void
debug_set_led(bool on)
{
gpio_write(gPeripheralBase + GPIO_BASE, 16, on ? 0 : 1);
sLedState = on;
}
void
debug_toggle_led(int count, int delay)
{
for (count *= 2; count > 0; count--) {
debug_set_led(!sLedState);
debug_delay(delay);
}
}
void
debug_blink_number(int number)
{
bool previousState = sLedState;
debug_set_led(false);
debug_delay(DEBUG_DELAY_LONG);
while (number > 0) {
debug_toggle_led(number % 10 + 1, DEBUG_DELAY_SHORT);
debug_delay(DEBUG_DELAY_LONG);
number /= 10;
}
debug_set_led(true);
debug_delay(DEBUG_DELAY_LONG);
debug_set_led(previousState);
}
void
debug_halt()
{
while (true)
debug_delay(DEBUG_DELAY_LONG);
}
void
debug_assert(bool condition)
{
if (condition)
return;
debug_toggle_led(20, 20);
debug_halt();
}
extern "C" void
debug_puts(const char* string, int32 length)
{
platform_video_puts(string);
serial_puts(string, length);
}
extern "C" void
panic(const char* format, ...)
{
const char hint[] = "\n*** PANIC ***\n";
char buffer[512];
va_list list;
int length;
debug_puts(hint, sizeof(hint));
va_start(list, format);
length = vsnprintf(buffer, sizeof(buffer), format, list);
va_end(list);
if (length >= (int)sizeof(buffer))
length = sizeof(buffer) - 1;
debug_puts(buffer, length);
//fprintf(stderr, "%s", buffer);
debug_puts("\nPress key to reboot.", 21);
platform_exit();
}
extern "C" void
dprintf(const char* format, ...)
{
char buffer[512];
va_list list;
int length;
va_start(list, format);
length = vsnprintf(buffer, sizeof(buffer), format, list);
va_end(list);
if (length >= (int)sizeof(buffer))
length = sizeof(buffer) - 1;
debug_puts(buffer, length);
if (platform_boot_options() & BOOT_OPTION_DEBUG_OUTPUT)
fprintf(stderr, "%s", buffer);
}
char*
platform_debug_get_log_buffer(size_t* _size)
{
return NULL;
}
@@ -1,34 +0,0 @@
.section .init
.globl _entry
_entry:
b jmp_loader
.section .text
/* Start "safe" code area.
* 0x4000 minimum safe area
* defined in boot_loader_raspberrypi_arm.ld
*/
jmp_loader:
/* Start Haiku loader */
/* For Thumb code? */
/*
ldr r12, =_start
mov lr, pc
bx r12
*/
/* Turn on unaligned memory access */
mrc p15, #0, r4, c1, c0, #0
orr r4, #0x400000
mcr p15, #0, r4, c1, c0, #0
/* Setup initial stack right below our .text section (growing downwards
into the space reserved for .init) */
mov sp, #0x8000
b _start
/* Cause exception if loader returns */
swi 0xFFFFFF
@@ -1,102 +0,0 @@
/*
* Copyright 2011-2012 Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Alexander von Gluck, [email protected]
* Gordon Henderson, [email protected]
*/
#include "gpio.h"
// Define the shift up for the 3 bits per pin in each GPFSEL port
static uint8_t
kGPIOToShift[] =
{
0, 3, 6, 9, 12, 15, 18, 21, 24, 27,
0, 3, 6, 9, 12, 15, 18, 21, 24, 27,
0, 3, 6, 9, 12, 15, 18, 21, 24, 27,
0, 3, 6, 9, 12, 15, 18, 21, 24, 27,
0, 3, 6, 9, 12, 15, 18, 21, 24, 27,
};
// Map a BCM_GPIO pin to it's control port. (GPFSEL 0-5)
static uint8_t
kGPIOToGPFSEL[] =
{
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
};
// (Word) offset to the GPIO Set registers for each GPIO pin
static uint8_t
kGPIOToGPSET[] =
{
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
};
// (Word) offset to the GPIO Clear registers for each GPIO pin
static uint8_t
kGPIOToGPCLR[] =
{
10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
};
/*!
* At GPIO (base) (pin) state set (value)
*/
void
gpio_write(addr_t base, int pin, bool value)
{
volatile addr_t *gpio = (addr_t*)base;
if (value == 1)
*(gpio + kGPIOToGPSET[pin]) = 1 << pin;
else
*(gpio + kGPIOToGPCLR[pin]) = 1 << pin;
}
/*!
* At GPIO (base) (pin) set mode (mode)
*/
void
gpio_mode(addr_t base, int pin, int mode)
{
int sel = kGPIOToGPFSEL[pin];
int shift = kGPIOToShift[pin];
volatile addr_t *gpio = (addr_t*)base + sel;
if (mode == GPIO_IN)
*gpio = (*gpio & ~(7 << shift));
else if (mode == GPIO_OUT)
*gpio = (*gpio & ~(7 << shift)) | (1 << shift);
else
*gpio = (*gpio & ~(7 << shift)) | (mode << shift);
}
void
gpio_init()
{
// ** Take control of ok led, and general use pins
int pin = 0;
for (pin = 16; pin <= 25; pin++)
gpio_mode(GPIO_BASE, pin, GPIO_OUT);
}
@@ -1,44 +0,0 @@
/*
* Copyright 2011-2012 Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Alexander von Gluck, [email protected]
*/
#ifndef _SYSTEM_BOOT_PLATFORM_PI_GPIO_H
#define _SYSTEM_BOOT_PLATFORM_PI_GPIO_H
#include <SupportDefs.h>
#include <arch/arm/bcm283X.h>
#define GPIO_IN 0
#define GPIO_OUT 1
#define GPIO_ALT0 4
#define GPIO_ALT1 5
#define GPIO_ALT2 6
#define GPIO_ALT3 7
#define GPIO_ALT4 3
#define GPIO_ALT5 2
#ifdef __cplusplus
extern "C" {
#endif
void gpio_write(addr_t base, int pin, bool value);
void gpio_mode(addr_t base, int pin, int mode);
void gpio_init();
#ifdef __cplusplus
}
#endif
#endif /* _SYSTEM_BOOT_PLATFORM_PI_GPIO_H */
@@ -1,43 +0,0 @@
/*
* Copyright 2009 Jonas Sundström, [email protected]
* All rights reserved. Distributed under the terms of the MIT License.
*/
#include "keyboard.h"
#include <boot/platform.h>
static uint16
check_for_key(void)
{
#warning IMPLEMENT check_for_key
return 0;
}
extern "C" void
clear_key_buffer(void)
{
#warning IMPLEMENT clear_key_buffer
while (check_for_key() != 0)
;
}
extern "C" union key
wait_for_key(void)
{
#warning IMPLEMENT wait_for_key
union key key;
return key;
}
extern "C" uint32
check_for_boot_keys(void)
{
#warning IMPLEMENT check_for_boot_keys
return 0;
}
@@ -1,33 +0,0 @@
/*
* Copyright 2009 Jonas Sundström, [email protected]
* All rights reserved. Distributed under the terms of the MIT License.
*/
#ifndef _SYSTEM_BOOT_PLATFORM_PI_KEYBOARD_H
#define _SYSTEM_BOOT_PLATFORM_PI_KEYBOARD_H
#include <SupportDefs.h>
union key {
uint16 ax;
struct {
uint8 ascii;
uint8 bios;
} code;
};
#ifdef __cplusplus
extern "C" {
#endif
extern void clear_key_buffer(void);
extern union key wait_for_key(void);
extern uint32 check_for_boot_keys(void);
#ifdef __cplusplus
}
#endif
#endif /* _SYSTEM_BOOT_PLATFORM_PI_KEYBOARD_H */
@@ -1,53 +0,0 @@
/*
* Copyright 2009 Jonas Sundström, [email protected]
* All rights reserved. Distributed under the terms of the MIT License.
*/
#include <boot/menu.h>
#include <boot/platform/generic/text_menu.h>
void
platform_add_menus(Menu* menu)
{
MenuItem* item;
switch (menu->Type()) {
case MAIN_MENU:
case SAFE_MODE_MENU:
menu->AddItem(item = new(nothrow) MenuItem("A menu item"));
item->SetType(MENU_ITEM_MARKABLE);
item->SetData(0);
item->SetHelpText("A helpful text.");
menu->AddItem(item = new(nothrow) MenuItem("Another menu item"));
item->SetHelpText("Some more helpful text.");
item->SetType(MENU_ITEM_MARKABLE);
break;
default:
break;
}
}
void
platform_update_menu_item(Menu* menu, MenuItem* item)
{
platform_generic_update_text_menu_item(menu, item);
}
void
platform_run_menu(Menu* menu)
{
platform_generic_run_text_menu(menu);
}
void
platform_get_user_input_text(Menu *menu, MenuItem *item, char *buffer,
size_t bufferSize)
{
platform_generic_get_user_input_text(menu, item, buffer, bufferSize);
}
@@ -1,99 +0,0 @@
/*
* Copyright 2004-2008, Axel Dörfler, [email protected].
* Distributed under the terms of the MIT License.
*
* Copyright 2009 Jonas Sundström, [email protected]
* All rights reserved. Distributed under the terms of the MIT License.
*/
#include "serial.h"
#include "arch_uart_pl011.h"
#include "board_config.h"
#include <boot/platform.h>
#include <arch/cpu.h>
#include <boot/stage2.h>
#include <string.h>
DebugUART *gUART;
static bool sSerialEnabled = false;
extern addr_t gPeripheralBase;
static void
serial_putc(char c)
{
gUART->PutChar(c);
}
extern "C" int
serial_getc(bool wait)
{
return gUART->GetChar(wait);
}
extern "C" void
serial_puts(const char* string, size_t size)
{
if (!sSerialEnabled)
return;
while (size-- > 0) {
char c = string[0];
if (c == '\n') {
serial_putc('\r');
serial_putc('\n');
} else if (c != '\r')
serial_putc(c);
string++;
}
}
extern "C" void
serial_disable(void)
{
if (sSerialEnabled)
serial_cleanup();
gUART->Disable();
}
extern "C" void
serial_enable(void)
{
gUART->Enable();
sSerialEnabled = true;
}
extern "C" void
serial_cleanup(void)
{
sSerialEnabled = false;
gUART->FlushTx();
}
extern "C" void
serial_init(void)
{
gUART = arch_get_uart_pl011(BOARD_UART_DEBUG, BOARD_UART_CLOCK);
gUART->InitEarly();
gUART->InitPort(9600);
serial_enable();
serial_puts("\n\n********************\n", 23);
serial_puts("Haiku serial startup\n", 21);
}
@@ -1,30 +0,0 @@
/*
* Copyright 2009 Jonas Sundström, [email protected]
* All rights reserved. Distributed under the terms of the MIT License.
*/
#ifndef _SYSTEM_BOOT_PLATFORM_PI_SERIAL_H
#define _SYSTEM_BOOT_PLATFORM_PI_SERIAL_H
#include <SupportDefs.h>
#ifdef __cplusplus
extern "C" {
#endif
extern void serial_init(void);
extern void serial_cleanup(void);
extern void serial_disable(void);
extern void serial_enable(void);
extern void serial_puts(const char *string, size_t size);
extern int serial_getc(bool wait);
#ifdef __cplusplus
}
#endif
#endif /* _SYSTEM_BOOT_PLATFORM_PI_SERIAL_H */
@@ -1,159 +0,0 @@
/*
* Copyright 2009 Jonas Sundström, [email protected]
* Copyright 2003-2008 Axel Dörfler, [email protected]
* All rights reserved. Distributed under the terms of the MIT License.
*/
#include "console.h"
#include "arch_cpu.h"
#include "gpio.h"
#include "keyboard.h"
#include "arch_mmu.h"
#include "serial.h"
#include <KernelExport.h>
#include <arch/cpu.h>
#include <boot/platform.h>
#include <boot/heap.h>
#include <boot/stage2.h>
#include <platform_arch.h>
#include <string.h>
#define HEAP_SIZE 65536
// GCC defined globals
extern void (*__ctor_list)(void);
extern void (*__ctor_end)(void);
extern void (*__dtor_list)(void);
extern void (*__dtor_end)(void);
extern uint8 __bss_start;
extern uint8 __bss_end;
extern uint8 __stack_start;
extern uint8 __stack_end;
extern int main(stage2_args *args);
// Adjusted during mmu_init
addr_t gPeripheralBase = DEVICE_BASE;
static void
clear_bss(void)
{
memset(&__bss_start, 0, &__bss_end - &__bss_start);
}
static void
fill_stack(void)
{
memset(&__stack_start, 0xBEBEBEBE, &__stack_end - &__stack_start);
}
static void
call_ctors(void)
{
void (**f)(void);
for (f = &__ctor_list; f < &__ctor_end; f++) {
(**f)();
}
}
// #pragma mark -
void
abort(void)
{
panic("abort");
}
uint32
platform_boot_options(void)
{
#warning IMPLEMENT platform_boot_options
return 0;
}
void
platform_start_kernel(void)
{
preloaded_elf32_image *image = static_cast<preloaded_elf32_image *>(
gKernelArgs.kernel_image.Pointer());
addr_t kernelEntry = image->elf_header.e_entry;
addr_t stackTop
= gKernelArgs.cpu_kstack[0].start + gKernelArgs.cpu_kstack[0].size;
serial_cleanup();
mmu_init_for_kernel();
dprintf("kernel entry at %lx\n", kernelEntry);
status_t error = arch_start_kernel(&gKernelArgs, kernelEntry,
stackTop);
panic("kernel returned!\n");
}
void
platform_exit(void)
{
serial_cleanup();
// Wait for keypress on serial
serial_getc(true);
serial_disable();
}
extern "C" void
_start(void)
{
stage2_args args;
clear_bss();
fill_stack();
call_ctors();
cpu_init();
gpio_init();
// Flick on "OK" led, use pre-mmu firmware base
gpio_write(gPeripheralBase + GPIO_BASE, 16, 0);
// specify available physical memory, using 128MB for now
// TODO: support CPU/GPU memory split options
insert_physical_memory_range(SDRAM_BASE, 128 * 1024 * 1024);
// Reserve memory for boot archive before switching on MMU
insert_physical_allocated_range(BOOT_ARCHIVE_BASE, BOOT_ARCHIVE_SIZE);
// To debug mmu, enable serial_init above me!
mmu_init();
// Map in the boot archive loaded into memory by the firmware.
args.platform.boot_tgz_size = BOOT_ARCHIVE_SIZE;
args.platform.boot_tgz_data = (void*)mmu_map_physical_memory(
BOOT_ARCHIVE_BASE, args.platform.boot_tgz_size, kDefaultPageFlags);
serial_init();
console_init();
args.heap_size = HEAP_SIZE;
args.arguments = NULL;
main(&args);
}
@@ -1,98 +0,0 @@
/*
* Copyright 2009 Jonas Sundström, [email protected]
* All rights reserved. Distributed under the terms of the MIT License.
*/
#include <SupportDefs.h>
#include <boot/kernel_args.h>
#include <boot/stage2.h>
#include "arch_framebuffer.h"
#include "blue_screen.h"
#include "frame_buffer_console.h"
ArchFramebuffer *gFramebuffer = NULL;
static bool sOnScreenDebugOutputAvailable = false;
extern "C" void
platform_video_puts(const char* string)
{
if (sOnScreenDebugOutputAvailable)
blue_screen_puts(string);
}
extern "C" void
platform_set_palette(const uint8* palette)
{
#warning IMPLEMENT platform_set_palette
}
extern "C" void
platform_switch_to_logo(void)
{
#warning IMPLEMENT platform_switch_to_logo
}
extern "C" void
platform_switch_to_text_mode(void)
{
#warning IMPLEMENT platform_switch_to_text_mode
}
extern "C" status_t
platform_init_video(void)
{
extern ArchFramebuffer* arch_get_framebuffer_arm_bcm2835();
gFramebuffer = arch_get_framebuffer_arm_bcm2825();
if (gFramebuffer == NULL)
return B_ERROR;
status_t result = gFramebuffer->Probe();
if (result != B_OK)
return result;
result = gFramebuffer->Init();
if (result != B_OK)
return result;
result = gFramebuffer->SetDefaultMode();
if (result != B_OK)
return result;
result = frame_buffer_update(gFramebuffer->Base(), gFramebuffer->Width(),
gFramebuffer->Height(), gFramebuffer->Depth(),
gFramebuffer->BytesPerRow());
if (result != B_OK)
return result;
result = blue_screen_init();
if (result != B_OK)
return result;
result = blue_screen_enter(false);
if (result != B_OK)
return result;
blue_screen_puts("Welcome to early on-screen debug output on rPi!\n");
sOnScreenDebugOutputAvailable = true;
gKernelArgs.frame_buffer.physical_buffer.start
= gFramebuffer->PhysicalBase();
gKernelArgs.frame_buffer.physical_buffer.size = gFramebuffer->Size();
gKernelArgs.frame_buffer.bytes_per_row = gFramebuffer->BytesPerRow();
gKernelArgs.frame_buffer.width = gFramebuffer->Width();
gKernelArgs.frame_buffer.height = gFramebuffer->Height();
gKernelArgs.frame_buffer.depth = gFramebuffer->Depth();
gKernelArgs.frame_buffer.enabled = true;
return B_OK;
}
@@ -1,8 +0,0 @@
SubDir HAIKU_TOP src system kernel platform raspberrypi_arm ;
SubDirCcFlags $(TARGET_KERNEL_PIC_CCFLAGS) ;
SubDirC++Flags $(TARGET_KERNEL_PIC_CCFLAGS) ;
KernelMergeObject kernel_platform_raspberrypi_arm.o :
platform.cpp
;
@@ -1,3 +0,0 @@
/*
Just a dummy. No BIOS services are required in the kernel.
*/