- don't clobber the parameter regs in the entry point,
- fix entry point address for netbsd loader emulation,
- added a gUImage global to point to the uimage blob with the tgz,
- added tgz info to platform stage2 args,
- add simple uimage support, just dumps the header and gets the nth blob in the image, (seems we have a bug in the math code, some infos don't print),
- made devices.cpp use them to publish the MemoryDisk,
- add an haiku_loader_nbsd.ub target which puts both the loader and kernel_arm for now (need to replace with the tgz).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32295 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
François Revol 2009-08-13 05:28:30 +00:00
parent f4e0ad68b3
commit 01c8294cc7
9 changed files with 171 additions and 21 deletions

View File

@ -11,7 +11,7 @@ HAIKU_BOARD_DESCRIPTION = "Gumstix Overo" ;
HAIKU_BOARD_LOADER_BASE = 0x80008000 ;
# entry points (raw binary, and netbsd loader emulation)
HAIKU_BOARD_LOADER_ENTRY_RAW = 0x80008000 ;
HAIKU_BOARD_LOADER_ENTRY_NBSD = 0x80008004 ;
HAIKU_BOARD_LOADER_ENTRY_NBSD = 0x80008008 ;
# load address for haiku_loader uimage
# (must be different than real load address)
@ -36,7 +36,9 @@ HAIKU_BOARD_SDIMAGE_BFS_OFFSET = ;
# autoboot script
HAIKU_BOARD_SDIMAGE_UBOOT_SCRIPT_NAME = gumstix-factory.script ;
HAIKU_BOARD_SDIMAGE_UBOOT_SCRIPT = "if mmcinit; then \
HAIKU_BOARD_SDIMAGE_UBOOT_SCRIPT = "\
setenv bootargs debug_screen true; \
if mmcinit; then \
fatload mmc 0 $(HAIKU_BOARD_LOADER_UIBASE) haiku_loader.ub; \
bootm $(HAIKU_BOARD_LOADER_UIBASE); \
fi" ;
@ -44,6 +46,7 @@ fi" ;
HAIKU_BOARD_SDIMAGE_FILES =
haiku_loader
haiku_loader.ub
haiku_loader_nbsd.ub
$(HAIKU_BOARD_SDIMAGE_UBOOT_SCRIPT_NAME)
;

View File

@ -10,7 +10,7 @@ HAIKU_BOARD_DESCRIPTION = "Gumstix Verdex" ;
HAIKU_BOARD_LOADER_BASE = 0xa2000000 ;
# entry points (raw binary, and netbsd loader emulation)
HAIKU_BOARD_LOADER_ENTRY_RAW = 0xa2000000 ;
HAIKU_BOARD_LOADER_ENTRY_NBSD = 0xa2000004 ;
HAIKU_BOARD_LOADER_ENTRY_NBSD = 0xa2000008 ;
# load address for haiku_loader uimage
# (must be different than real load address)
@ -46,14 +46,17 @@ HAIKU_BOARD_SDIMAGE_FAT_SIZE = 32 ;
# autoboot script
HAIKU_BOARD_SDIMAGE_UBOOT_SCRIPT_NAME = gumstix-factory.script ;
HAIKU_BOARD_SDIMAGE_UBOOT_SCRIPT = "if mmcinit; then \
fatload mmc 0 $(HAIKU_BOARD_LOADER_UIBASE) haiku_loader.ub; \
HAIKU_BOARD_SDIMAGE_UBOOT_SCRIPT = "\
setenv bootargs debug_screen true; \
if mmcinit; then \
fatload mmc 0 $(HAIKU_BOARD_LOADER_UIBASE) haiku_loader_nbsd.ub; \
bootm $(HAIKU_BOARD_LOADER_UIBASE); \
fi" ;
HAIKU_BOARD_SDIMAGE_FILES =
haiku_loader
haiku_loader.ub
haiku_loader.ub
haiku_loader_nbsd.ub
$(HAIKU_BOARD_SDIMAGE_UBOOT_SCRIPT_NAME)
;

View File

@ -10,6 +10,8 @@
#endif
struct platform_stage2_args {
void *boot_tgz_data;
uint32 boot_tgz_size;
};
#endif /* KERNEL_BOOT_PLATFORM_UBOOT_STAGE2_H */

View File

@ -0,0 +1,54 @@
/*
* Copyright 2009 Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* François Revol, revol@free.fr
*/
#ifndef KERNEL_BOOT_PLATFORM_UBOOT_UIMAGE_H
#define KERNEL_BOOT_PLATFORM_UBOOT_UIMAGE_H
#include <SupportDefs.h>
/* same type and constant names as U-Boot */
#define IH_TYPE_STANDALONE 1
#define IH_TYPE_KERNEL 2
#define IH_TYPE_RAMDISK 3
#define IH_TYPE_MULTI 4
#define IH_COMP_NONE 0
#define IH_MAGIC 0x27051956
#define IH_NMLEN 32
typedef struct image_header {
uint32 ih_magic;
uint32 ih_hcrc;
uint32 ih_time;
uint32 ih_size;
uint32 ih_load;
uint32 ih_ep;
uint32 ih_dcrc;
uint8 ih_os;
uint8 ih_arch;
uint8 ih_type;
uint8 ih_comp;
char ih_name[IH_NMLEN];
} image_header_t;
#ifdef __cplusplus
extern "C" {
#endif
void dump_uimage(struct image_header *image);
bool image_multi_getimg(struct image_header *image, uint32 idx,
uint32 *data, uint32 *size);
#ifdef __cplusplus
}
#endif
#endif /* KERNEL_BOOT_PLATFORM_UBOOT_UIMAGE_H */

View File

@ -22,7 +22,7 @@ local uImageFakeOS = "netbsd" ;
SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src add-ons accelerants common ] ;
KernelMergeObject boot_platform_u-boot.o :
start.S
shell.S
start2.c
debug.c
console.cpp
@ -31,6 +31,7 @@ KernelMergeObject boot_platform_u-boot.o :
keyboard.cpp
menu.cpp
cpu.cpp
uimage.cpp
video.cpp
mmu.cpp
# generic
@ -96,12 +97,14 @@ rule BuildUImage image : data : args
Depends $(image) : $(data) ;
LocalClean clean : $(image) ;
MKIMAGE_ARGS on $(image) = $(args) ;
colon on $(image) = ":" ;
local files = $(data:G=) ;
BuildUImage1 $(image) : $(data) ;
}
actions BuildUImage1
{
mkimage $(MKIMAGE_ARGS) -d $(>) $(<)
mkimage $(MKIMAGE_ARGS) -d $(>:J=$(colon)) $(<)
}
rule BuildUImageScript script : content
@ -170,8 +173,12 @@ BuildUImage haiku_loader.ub : haiku_loader :
-a $(HAIKU_BOARD_LOADER_BASE) -e $(HAIKU_BOARD_LOADER_ENTRY_RAW)
-n 'haiku_loader' ;
BuildUImage haiku_loader_nbsd.ub : haiku_loader kernel_arm :
-A arm -O $(uImageFakeOS) -T multi -C none
-a $(HAIKU_BOARD_LOADER_BASE) -e $(HAIKU_BOARD_LOADER_ENTRY_NBSD)
-n 'haiku_loader' ;
if $(HAIKU_BOARD_SDIMAGE_UBOOT_SCRIPT_NAME) {
BuildUImageScript $(HAIKU_BOARD_SDIMAGE_UBOOT_SCRIPT_NAME) :
$(HAIKU_BOARD_SDIMAGE_UBOOT_SCRIPT) ;
}
@ -187,6 +194,8 @@ BuildUBootFlashImage haiku_flash_image_uimage.img : haiku_loader.ub :
# SD/mmc image targets
BuildUBootSDImage haiku.mmc : $(HAIKU_BOARD_SDIMAGE_FILES) ;
SEARCH on [ FGristFiles shell.S ]
= [ FDirName $(HAIKU_TOP) src system boot platform $(TARGET_BOOT_PLATFORM) arch $(TARGET_ARCH) ] ;
SEARCH on [ FGristFiles text_menu.cpp ]
= [ FDirName $(HAIKU_TOP) src system boot platform generic ] ;

View File

@ -18,7 +18,7 @@ SYMBOL(_start_raw):
* ELF entry
*/
SYMBOL(_start):
mov r0,#0
mov r4,#0
b _start_common
SYMBOL_END(_start_raw)
SYMBOL_END(_start)
@ -27,20 +27,20 @@ SYMBOL_END(_start)
* called from bootm with netbsd loader compatible args
*/
SYMBOL(_start_netbsd):
mov r0,#1
mov r4,#1
b _start_common
SYMBOL_END(_start_netbsd)
SYMBOL(_start_common):
strb r0,gUBootOS
strb r4,gUBootOS
str r8,gUBootGlobalData
/* ... */
ldrb r0,gUBootOS
cmp r0,#0
ldrb r4,gUBootOS
cmp r4,#0
beq start_raw
cmp r0,#1
cmp r4,#1
beq start_netbsd
mov pc,lr
SYMBOL_END(_start_common)
@ -51,6 +51,9 @@ SYMBOL_END(_start_common)
SYMBOL(gUBootGlobalData):
.long 0
SYMBOL_END(gUBootGlobalData)
SYMBOL(gUImage):
.long 0
SYMBOL_END(gUImage)
SYMBOL(gUBootOS):
.byte 0
SYMBOL_END(gUBootOS)

View File

@ -23,13 +23,14 @@
status_t
platform_add_boot_device(struct stage2_args *args, NodeList *devicesList)
{
#warning ARM: correct/configurable "initrd" location
uint8* data = (uint8*)0xa5000000;
size_t size = 0;
TRACE("platform_add_boot_device\n");
MemoryDisk* disk = new(nothrow) MemoryDisk(data, size, "boot.tgz");
if (!args->platform.boot_tgz_data || !args->platform.boot_tgz_size)
return B_DEVICE_NOT_FOUND;
MemoryDisk* disk = new(nothrow) MemoryDisk(
(const uint8 *)args->platform.boot_tgz_data,
args->platform.boot_tgz_size, "boot.tgz");
if (!disk) {
dprintf("platform_add_boot_device(): Could not create MemoryDisk !\n");
return B_NO_MEMORY;

View File

@ -8,6 +8,7 @@
#include "console.h"
#include "cpu.h"
#include "smp.h"
#include "uimage.h"
#include "keyboard.h"
#include <KernelExport.h>
@ -31,6 +32,8 @@ extern uint8 _end;
extern int main(stage2_args *args);
extern void _start(void);
extern int start_raw(int argc, char **argv);
extern void dump_uimage(struct image_header *image);
extern struct image_header *gUImage;
uint32 sBootOptions;
@ -116,13 +119,14 @@ extern uboot_arm_gd *gUBootGlobalData;
extern uint8 gUBootOS;
int
start_netbsd(struct board_info *bd, struct uimage *image, const char *consdev,
start_netbsd(struct board_info *bd, struct image_header *image, const char *consdev,
const char *cmdline)
{
const char *argv[] = { "haiku", cmdline };
int argc = 1;
if (cmdline)
argc++;
gUImage = image;
start_raw(argc, argv);
}
@ -142,6 +146,13 @@ start_raw(int argc, char **argv)
call_ctors();
args.heap_size = HEAP_SIZE;
args.arguments = NULL;
args.platform.boot_tgz_data = NULL;
args.platform.boot_tgz_size = 0;
// if we get passed a uimage, try to find the second blob
if (gUImage)
image_multi_getimg(gUImage, 1, &args.platform.boot_tgz_data,
&args.platform.boot_tgz_size);
serial_init();
@ -156,6 +167,9 @@ start_raw(int argc, char **argv)
dprintf("os: %d\n", gUBootOS);
dprintf("gd @ %p\n", gGD);
dprintf("gd->bd @ %p\n", gGD->bd);
dprintf("uimage @ %p\n", gUImage);
if (gUImage)
dump_uimage(gUImage);
}
// mmu_init();

View File

@ -0,0 +1,61 @@
/*
* Copyright 2009, François Revol, revol@free.fr.
* Distributed under the terms of the MIT License.
*/
#include <uimage.h>
#include <KernelExport.h>
#include <ByteOrder.h>
void dump_uimage(struct image_header *image)
{
uint32 *sizes;
int i;
dprintf("uimage @ %p:\n", image);
if (!image)
return;
dprintf("magic: %x\n", ntohl(image->ih_magic));
dprintf("size: %x\n", ntohl(image->ih_size));
dprintf("load: %p\n", (void *)ntohl(image->ih_load));
dprintf("ep: %d\n", (void *)ntohl(image->ih_ep));
dprintf("os: %d\n", image->ih_os);
dprintf("arch: %d\n", image->ih_arch);
dprintf("type: %d\n", image->ih_type);
dprintf("comp: %d\n", image->ih_comp);
dprintf("name: '%32.32s'\n", image->ih_name);
if (image->ih_type != IH_TYPE_MULTI)
return;
sizes = (uint32 *)(&image[1]);
for (i = 0; sizes[i]; i++) {
dprintf("contents[%d] :", i);
dprintf("%x bytes\n", (int)ntohl(sizes[i]));
}
}
bool
image_multi_getimg(struct image_header *image, uint32 idx, uint32 *data, uint32 *size)
{
uint32 *sizes;
uint32 base;
int i, count = 0;
sizes = (uint32 *)(&image[1]);
base = (uint32)sizes;
for (i = 0; sizes[i]; i++)
count++;
base += (count + 1) * sizeof(uint32);
for (i = 0; sizes[i] && idx < i; i++) {
if (idx == i) {
*data = base;
*size = ntohl(sizes[i]);
return true;
}
}
return false;
}