Adding routerboard_mipsel platform stubs and linker script.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32594 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jonas Sundström 2009-08-22 01:48:18 +00:00
parent b5172954bb
commit 8e8130d1f0
23 changed files with 936 additions and 3 deletions

View File

@ -233,10 +233,11 @@ switch $(HAIKU_CPU) {
{
HAIKU_DEFINES += __MIPSEL__ ;
# RouterBOARD firmware (ELF image over TFTP)
HAIKU_BOOT_PLATFORM = routerboot_mipsel ;
HAIKU_BOOT_PLATFORM = routerboard_mipsel ;
# offset in floppy image (>= sizeof(haiku_loader))
HAIKU_BOOT_ARCHIVE_IMAGE_OFFSET = 192 ; # in kB - todo/fixme
HAIKU_NO_WERROR = 1 ; # we use #warning as placeholders for things to write...
HAIKU_BOOT_ARCHIVE_IMAGE_OFFSET = 192 ; # in kB
HAIKU_NO_WERROR = 1 ;
# we use #warning as placeholders for things to write...
}
case * :
Exit "Currently unsupported target CPU:" $(HAIKU_CPU) ;

View File

@ -0,0 +1,40 @@
/*
* Copyright 2009 Jonas Sundström, jonas@kirilla.com
* All rights reserved. Distributed under the terms of the MIT License.
*/
#ifndef _KERNEL_BOOT_PLATFORM_ROUTERBOARD_MIPSEL_ARCH_H
#define _KERNEL_BOOT_PLATFORM_ROUTERBOARD_MIPSEL_ARCH_H
#include <SupportDefs.h>
#warning IMPLEMENT platform_arch.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_ROUTERBOARD_MIPSEL_ARCH_H */

View File

@ -0,0 +1,27 @@
/*
* Copyright 2009 Jonas Sundström, jonas@kirilla.com
* All rights reserved. Distributed under the terms of the MIT License.
*/
#ifndef _KERNEL_BOOT_PLATFORM_ROUTERBOARD_MIPSEL_KERNEL_ARGS_H
#define _KERNEL_BOOT_PLATFORM_ROUTERBOARD_MIPSEL_KERNEL_ARGS_H
#ifndef KERNEL_BOOT_KERNEL_ARGS_H
# error This file is included from <boot/kernel_args.h> only
#endif
#warning IMPLEMENT platform_kernel_args.h
// must match SMP_MAX_CPUS in arch_smp.h
#define MAX_BOOT_CPUS 1
#define MAX_PHYSICAL_MEMORY_RANGE 4
#define MAX_PHYSICAL_ALLOCATED_RANGE 8
#define MAX_VIRTUAL_ALLOCATED_RANGE 32
typedef struct {
void* whateverPointer;
char whateverPath[128];
} platform_kernel_args;
#endif /* _KERNEL_BOOT_PLATFORM_ROUTERBOARD_MIPSEL_KERNEL_ARGS_H */

View File

@ -0,0 +1,18 @@
/*
* Copyright 2009 Jonas Sundström, jonas@kirilla.com
* All rights reserved. Distributed under the terms of the MIT License.
*/
#ifndef _KERNEL_BOOT_PLATFORM_ROUTERBOARD_MIPSEL_STAGE2_ARGS_H
#define _KERNEL_BOOT_PLATFORM_ROUTERBOARD_MIPSEL_STAGE2_ARGS_H
#ifndef KERNEL_BOOT_STAGE2_ARGS_H
# error This file is included from <boot/stage2_args.h> only
#endif
#warning IMPLEMENT platform_stage2_args.h
struct platform_stage2_args {
};
#endif /* _KERNEL_BOOT_PLATFORM_ROUTERBOARD_MIPSEL_STAGE2_ARGS_H */

View File

@ -0,0 +1,50 @@
SubDir HAIKU_TOP src system boot platform routerboard_mipsel ;
SubDirHdrs $(HAIKU_TOP) headers private kernel boot platform $(TARGET_BOOT_PLATFORM) ;
UsePrivateHeaders [ FDirName kernel disk_device_manager ] ;
UsePrivateHeaders [ FDirName graphics common ] ;
UsePrivateHeaders [ FDirName graphics vesa ] ;
UsePrivateHeaders [ FDirName storage ] ;
{
local defines = _BOOT_MODE ;
defines = [ FDefines $(defines) ] ;
SubDirCcFlags $(defines) -Wall -Wno-multichar ;
SubDirC++Flags $(defines) -Wall -Wno-multichar -fno-rtti ;
}
SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src add-ons accelerants common ] ;
local genericPlatformSources =
text_menu.cpp
# video_blit.cpp
# video_splash.cpp
# video_rle.cpp
;
KernelMergeObject boot_platform_routerboard_mipsel.o :
console.cpp
cpu.cpp
debug.c
devices.cpp
keyboard.cpp
menu.cpp
mmu.cpp
serial.cpp
start.c
video.cpp
$(genericPlatformSources)
: -fno-pic -G0
;
SEARCH on [ FGristFiles $(genericPlatformSources) ]
= [ FDirName $(HAIKU_TOP) src system boot platform generic ] ;
# Tell the build system to where stage1.bin can be found, so it can be used
# elsewhere.
SEARCH on stage1.bin = $(SUBDIR) ;

View File

@ -0,0 +1,116 @@
/*
* Copyright 2009 Jonas Sundström, jonas@kirilla.com
* All rights reserved. Distributed under the terms of the MIT License.
*/
#include "console.h"
#include <SupportDefs.h>
#include "keyboard.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);
};
static uint32 sScreenWidth = 80;
static uint32 sScreenHeight = 25;
static uint32 sScreenOffset = 0;
static uint16 sColor = 0x0f00;
static Console sInput, sOutput;
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)
{
#warning IMPLEMENT ReadAt
return 0;
}
ssize_t
Console::WriteAt(void* cookie, off_t /*pos*/, const void* buffer, size_t bufferSize)
{
#warning IMPLEMENT WriteAt
return 0;
}
// #pragma mark -
void
console_clear_screen(void)
{
#warning IMPLEMENT console_clear_screen
}
int32
console_width(void)
{
#warning IMPLEMENT console_width
return 0;
}
int32
console_height(void)
{
#warning IMPLEMENT console_height
return 0;
}
void
console_set_cursor(int32 x, int32 y)
{
#warning IMPLEMENT console_set_cursor
}
void
console_set_color(int32 foreground, int32 background)
{
#warning IMPLEMENT console_set_color
}
int
console_wait_for_key(void)
{
#warning IMPLEMENT console_wait_for_key
union key key;
return key.code.ascii;
}
status_t
console_init(void)
{
#warning IMPLEMENT console_init
return B_OK;
}

View File

@ -0,0 +1,21 @@
/*
* Copyright 2009 Jonas Sundström, jonas@kirilla.com
* All rights reserved. Distributed under the terms of the MIT License.
*/
#ifndef _SYSTEM_BOOT_PLATFORM_ROUTERBOARD_MIPSEL_CONSOLE_H
#define _SYSTEM_BOOT_PLATFORM_ROUTERBOARD_MIPSEL_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_ROUTERBOARD_MIPSEL_CONSOLE_H */

View File

@ -0,0 +1,40 @@
/*
* Copyright 2009 Jonas Sundström, jonas@kirilla.com
* All rights reserved. Distributed under the terms of the MIT License.
*/
#include "cpu.h"
#include <OS.h>
#include <arch/cpu.h>
#include <arch_kernel.h>
#include <arch_system_info.h>
#include <string.h>
static status_t
check_cpu_features()
{
#warning IMPLEMENT check_cpu_features
return B_ERROR;
}
// #pragma mark -
extern "C" void
spin(bigtime_t microseconds)
{
#warning IMPLEMENT spin
}
extern "C" void
cpu_init()
{
#warning IMPLEMENT cpu_init
}

View File

@ -0,0 +1,23 @@
/*
* Copyright 2009 Jonas Sundström, jonas@kirilla.com
* All rights reserved. Distributed under the terms of the MIT License.
*/
#ifndef _SYSTEM_BOOT_PLATFORM_ROUTERBOARD_MIPSEL_CPU_H
#define _SYSTEM_BOOT_PLATFORM_ROUTERBOARD_MIPSEL_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 */

View File

@ -0,0 +1,24 @@
/*
* Copyright 2009 Jonas Sundström, jonas@kirilla.com
* All rights reserved. Distributed under the terms of the MIT License.
*/
#include <boot/platform.h>
#include <boot/stdio.h>
#include <stdarg.h>
void
panic(const char* format, ...)
{
#warning IMPLEMENT panic
}
void
dprintf(const char* format, ...)
{
#warning IMPLEMENT dprintf
}

View File

@ -0,0 +1,47 @@
/*
* Copyright 2009 Jonas Sundström, jonas@kirilla.com
* All rights reserved. Distributed under the terms of the MIT License.
*/
#include <KernelExport.h>
#include <boot/platform.h>
#include <boot/partitions.h>
#include <boot/stdio.h>
#include <boot/stage2.h>
#include <string.h>
status_t
platform_add_boot_device(struct stage2_args* args, NodeList* devicesList)
{
#warning IMPLEMENT platform_add_boot_device
return B_ERROR;
}
status_t
platform_get_boot_partition(struct stage2_args* args, Node* bootDevice,
NodeList* list, boot::Partition** _partition)
{
#warning IMPLEMENT platform_get_boot_partition
return B_ERROR;
}
status_t
platform_add_block_devices(stage2_args* args, NodeList* devicesList)
{
#warning IMPLEMENT platform_add_block_devices
return B_ERROR;
}
status_t
platform_register_boot_device(Node* device)
{
#warning IMPLEMENT platform_register_boot_device
return B_ERROR;
}

View File

@ -0,0 +1,44 @@
/*
* Copyright 2009 Jonas Sundström, jonas@kirilla.com
* 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;
}

View File

@ -0,0 +1,34 @@
/*
* Copyright 2009 Jonas Sundström, jonas@kirilla.com
* All rights reserved. Distributed under the terms of the MIT License.
*/
#ifndef _SYSTEM_BOOT_PLATFORM_ROUTERBOARD_MIPSEL_KEYBOARD_H
#define _SYSTEM_BOOT_PLATFORM_ROUTERBOARD_MIPSEL_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_ROUTERBOARD_MIPSEL_KEYBOARD_H */

View File

@ -0,0 +1,46 @@
/*
* Copyright 2009 Jonas Sundström, jonas@kirilla.com
* 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);
}

View File

@ -0,0 +1,95 @@
/*
* Copyright 2009 Jonas Sundström, jonas@kirilla.com
* All rights reserved. Distributed under the terms of the MIT License.
*/
#include "mmu.h"
#include <boot/platform.h>
#include <boot/stdio.h>
#include <boot/kernel_args.h>
#include <boot/stage2.h>
#include <arch/cpu.h>
#include <arch_kernel.h>
#include <kernel.h>
#include <OS.h>
#include <string.h>
// #pragma mark -
extern "C" addr_t
mmu_map_physical_memory(addr_t physicalAddress, size_t size, uint32 flags)
{
#warning IMPLEMENT mmu_map_physical_memory
return 0;
}
extern "C" void*
mmu_allocate(void* virtualAddress, size_t size)
{
#warning IMPLEMENT mmu_allocate
return 0;
}
extern "C" void
mmu_free(void* virtualAddress, size_t size)
{
#warning IMPLEMENT mmu_free
}
extern "C" void
mmu_init_for_kernel(void)
{
#warning IMPLEMENT mmu_init_for_kernel
}
extern "C" void
mmu_init(void)
{
#warning IMPLEMENT mmu_init
}
// #pragma mark -
extern "C" status_t
platform_allocate_region(void** _address, size_t size, uint8 protection,
bool /*exactAddress*/)
{
#warning IMPLEMENT platform_allocate_region
return B_ERROR;
}
extern "C" status_t
platform_free_region(void* address, size_t size)
{
#warning IMPLEMENT platform_free_region
return B_ERROR;
}
void
platform_release_heap(struct stage2_args* args, void* base)
{
#warning IMPLEMENT platform_release_heap
}
status_t
platform_init_heap(struct stage2_args* args, void** _base, void** _top)
{
#warning IMPLEMENT platform_init_heap
return B_ERROR;
}

View File

@ -0,0 +1,30 @@
/*
* Copyright 2009 Jonas Sundström, jonas@kirilla.com
* All rights reserved. Distributed under the terms of the MIT License.
*/
#ifndef _SYSTEM_BOOT_PLATFORM_ROUTERBOARD_MIPSEL_MMU_H
#define _SYSTEM_BOOT_PLATFORM_ROUTERBOARD_MIPSEL_MMU_H
#include <SupportDefs.h>
#ifdef __cplusplus
extern "C" {
#endif
extern void mmu_init(void);
extern void mmu_init_for_kernel(void);
extern addr_t mmu_map_physical_memory(addr_t physicalAddress, size_t size,
uint32 flags);
extern void* mmu_allocate(void* virtualAddress, size_t size);
extern void mmu_free(void* virtualAddress, size_t size);
#ifdef __cplusplus
}
#endif
#endif /* _SYSTEM_BOOT_PLATFORM_ROUTERBOARD_MIPSEL_MMU_H */

View File

@ -0,0 +1,56 @@
/*
* Copyright 2009 Jonas Sundström, jonas@kirilla.com
* All rights reserved. Distributed under the terms of the MIT License.
*/
#include "serial.h"
#include <boot/platform.h>
#include <arch/cpu.h>
#include <boot/stage2.h>
#include <string.h>
static void
serial_putc(char c)
{
#warning IMPLEMENT serial_putc
}
extern "C" void
serial_puts(const char* string, size_t size)
{
#warning IMPLEMENT serial_puts
}
extern "C" void
serial_disable(void)
{
#warning IMPLEMENT serial_disable
}
extern "C" void
serial_enable(void)
{
#warning IMPLEMENT serial_enable
}
extern "C" void
serial_cleanup(void)
{
#warning IMPLEMENT serial_cleanup
}
extern "C" void
serial_init(void)
{
#warning IMPLEMENT serial_init
}

View File

@ -0,0 +1,27 @@
/*
* Copyright 2009 Jonas Sundström, jonas@kirilla.com
* All rights reserved. Distributed under the terms of the MIT License.
*/
#ifndef _SYSTEM_BOOT_PLATFORM_ROUTERBOARD_MIPSEL_SERIAL_H
#define _SYSTEM_BOOT_PLATFORM_ROUTERBOARD_MIPSEL_SERIAL_H
#include <SupportDefs.h>
#ifdef __cplusplus
extern "C" {
#endif
extern void serial_init(void);
extern void serial_cleanup(void);
extern void serial_puts(const char *string, size_t size);
extern void serial_disable(void);
extern void serial_enable(void);
#ifdef __cplusplus
}
#endif
#endif /* _SYSTEM_BOOT_PLATFORM_ROUTERBOARD_MIPSEL_SERIAL_H */

View File

@ -0,0 +1,110 @@
/*
* Copyright 2009 Jonas Sundström, jonas@kirilla.com
* Copyright 2003-2008 Axel Dörfler, axeld@pinc-software.de
* All rights reserved. Distributed under the terms of the MIT License.
*/
#include "serial.h"
#include "console.h"
#include "cpu.h"
#include "mmu.h"
#include "keyboard.h"
#include <KernelExport.h>
#include <boot/platform.h>
#include <boot/heap.h>
#include <boot/stage2.h>
#include <arch/cpu.h>
#include <string.h>
#define HEAP_SIZE 65536
// GCC defined globals
extern void (*__ctor_list)(void);
extern void (*__ctor_end)(void);
extern uint8 __bss_start;
extern uint8 _end;
extern int main(stage2_args *args);
void _start(void);
static void
clear_bss(void)
{
/* TODO: fix boot_loader_routerboard_mipsel.ld
* so this code works, or find a workaround.
*/
/*
memset(&__bss_start, 0, &_end - &__bss_start);
*/
}
static void
call_ctors(void)
{
/* TODO: fix boot_loader_routerboard_mipsel.ld
* so this code works, or find a workaround.
*/
/*
void (**f)(void);
for (f = &__ctor_list; f < &__ctor_end; f++) {
(**f)();
}
*/
}
// #pragma mark -
uint32
platform_boot_options(void)
{
#warning IMPLEMENT platform_boot_options
return 0;
}
void
platform_start_kernel(void)
{
#warning IMPLEMENT platform_start_kernel
panic("kernel returned!\n");
}
void
platform_exit(void)
{
#warning IMPLEMENT platform_exit
}
void
_start(void)
{
#warning IMPLEMENT _start
stage2_args args;
clear_bss();
call_ctors();
cpu_init();
mmu_init();
serial_init();
console_init();
serial_enable();
args.heap_size = HEAP_SIZE;
args.arguments = NULL;
main(&args);
}

View File

@ -0,0 +1,37 @@
/*
* Copyright 2009 Jonas Sundström, jonas@kirilla.com
* All rights reserved. Distributed under the terms of the MIT License.
*/
#include <SupportDefs.h>
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)
{
#warning IMPLEMENT platform_init_video
return B_ERROR;
}

View File

@ -0,0 +1,9 @@
SubDir HAIKU_TOP src system kernel platform routerboard_mipsel ;
SubDirCcFlags $(TARGET_KERNEL_PIC_CCFLAGS) ;
SubDirC++Flags $(TARGET_KERNEL_PIC_CCFLAGS) ;
KernelMergeObject kernel_platform_routerboard_mipsel.o :
platform.cpp
;

View File

@ -0,0 +1,3 @@
/*
Just a dummy. No BIOS services are required in the kernel.
*/

View File

@ -0,0 +1,35 @@
OUTPUT_FORMAT("elf32-littlemips")
OUTPUT_ARCH(mips)
ENTRY(_start)
SECTIONS
{
. = 0x10000;
/* text/read-only data */
.text : { *(.text .gnu.linkonce.t.*) }
__ctor_list = .;
.ctors : { *(.ctors) }
__ctor_end = .;
.rodata : { *(.rodata .rodata.*) }
/* writable data */
. = ALIGN(0x1000);
__data_start = .;
.data : { *(.data .gnu.linkonce.d.*) }
_gp = .;
/* needed for GPREL16 relocation to small-data section */
/* unintialized data (in same segment as writable data) */
__bss_start = .;
.bss : { *(.bss) }
. = ALIGN(0x1000);
_end = .;
/* Strip unnecessary stuff */
/DISCARD/ : { *(.comment .note .eh_frame .dtors .stab .stabstr .debug*) }
}