It's working \o/

Now starts doing stuff in the loader when bootstrapping the .prg from ARAnyM.
For now it just dumps the cookies.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23552 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
François Revol 2008-01-16 04:12:06 +00:00
parent 5c62817c6f
commit 7ef900d3ef
7 changed files with 143 additions and 73 deletions

View File

@ -18,8 +18,13 @@ UsePrivateHeaders [ FDirName storage ] ;
#SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src add-ons accelerants common ] ;
KernelMergeObject boot_platform_atari_m68k.o :
KernelMergeObject boot_platform_atari_m68k_shell.o :
shell.S
: -Wa,--pcrel
;
KernelMergeObject boot_platform_atari_m68k_other.o :
# shell.S
start.c
toscalls.S
debug.c
@ -45,7 +50,13 @@ KernelMergeObject boot_platform_atari_m68k.o :
#decode_edid.c
#dump_edid.c
: -fpic -Wa,--pcrel
: -fno-pic #-Wa,--pcrel
;
KernelMergeObject boot_platform_atari_m68k.o :
: :
boot_platform_atari_m68k_shell.o
boot_platform_atari_m68k_other.o
;
SEARCH on [ FGristFiles text_menu.cpp ]

View File

@ -31,17 +31,20 @@
#warning M68K: add set_vbr()
static status_t
check_cpu_features()
{
#warning M68K: TODO: probe ourselves, we shouldn't trust the TOS!
const tos_cookie *c;
c = tos_find_cookie('_CPU');
if (!c) {
panic("can't get a cookie (_CPU)! Mum, I'm hungry!");
return EINVAL;
}
dump_tos_cookies();
#warning M68K: check for 020 + mmu
if (c->ivalue < 30/*20*/)

View File

@ -24,7 +24,7 @@ panic(const char *format, ...)
//platform_switch_to_text_mode();
Bconputs(DEV_CONSOLE, "*** PANIC ***");
Bconputs(DEV_CONSOLE, "\n*** PANIC ***");
va_start(list, format);
length = vsnprintf(buffer, sizeof(buffer), format, list);
@ -51,10 +51,10 @@ dprintf(const char *format, ...)
length = vsnprintf(buffer, sizeof(buffer), format, list);
va_end(list);
Bconputs(DEV_AUX, buffer);
Bconput(DEV_AUX, buffer);
if (platform_boot_options() & BOOT_OPTION_DEBUG_OUTPUT)
Bconputs(DEV_CONSOLE, buffer);
//if (platform_boot_options() & BOOT_OPTION_DEBUG_OUTPUT)
Bconput(DEV_CONSOLE, buffer);
}
@ -145,3 +145,26 @@ status_t toserror(int32 err)
return B_ERROR;
}
}
void dump_tos_cookie(uint32 cookie)
{
const tos_cookie *c;
c = tos_find_cookie(cookie);
if (!c)
dprintf("%4.4s: nil\n", &cookie);
else
dprintf("%4.4s: 0x%08lx, %d\n", &cookie, c->ivalue, c->ivalue);
}
void dump_tos_cookies(void)
{
static const uint32 clist[] = { '_CPU', '_FPU', '_VDO', '_FDC',
'_SND', '_MCH', '_SWI', '_FRB',
'_FLK', '_NET', '_IDT', '_AKP',
'FSMC', 'SAM\0', 'MiNT', NULL };
int i;
dprintf("Cookies:\n");
for (i = 0; clist[i]; i++)
dump_tos_cookie(clist[i]);
}

View File

@ -13,6 +13,8 @@ SECTIONS
/*. = 0x80000000 + SIZEOF_HEADERS;*/
/* fool the alignment of .text */
/*. = 0x20 - 0x1c;*/
/* should stay in sync with boot_loader_m68k_atari.ld and atari_memory_map.h */
. = 0x00080000 - 0x1c ;
/* .PRG file header */
.prgheader : {
@ -24,37 +26,44 @@ SECTIONS
LONG(0) /* SYMBOL TABLE SIZE */
LONG(0x4841494b) /* (reserved) 'HAIK' */
LONG(0x1) /* PRGFLAGS : PF_FASTLOAD */
SHORT(0) /* ABSFLAG */
SHORT(1) /* ABSFLAG */
}
__text_start = .;
/* ".text ." should align to 0x1c but doesn't work as expected, cf top. */
.text . : {
.text : {
*(.text .gnu.linkonce.t.*)
*(.rel.text) *(.rel.gnu.linkonce.t*)
*(.rela.text) *(.rela.gnu.linkonce.t*)
/* *(.rel.text) *(.rel.gnu.linkonce.t*)
*(.rela.text) *(.rela.gnu.linkonce.t*) */
}
. = ALIGN(0x4);
__ctor_list = .;
.ctors : { *(.ctors) }
__ctor_end = .;
.rodata : {
*(.rodata)
*(.rel.rodata) *(.rel.gnu.linkonce.r*)
*(.rela.rodata) *(.rela.gnu.linkonce.r*)
/* *(.rel.rodata) *(.rel.gnu.linkonce.r*)
*(.rela.rodata) *(.rela.gnu.linkonce.r*) */
}
/* writable data */
/* NO! . = ALIGN(0x1000); */
. = ALIGN(0x1000);
__data_start = .;
.data : {
*(.data .gnu.linkonce.d.*)
*(.rel.data) *(.rel.gnu.linkonce.d*)
*(.rela.data) *(.rela.gnu.linkonce.d*)
/* *(.rel.data) *(.rel.gnu.linkonce.d*)
*(.rela.data) *(.rela.gnu.linkonce.d*) */
}
/* unintialized data (in same segment as writable data) */
__bss_start = .;
.bss : {
*(.bss)
*(.rel.bss)
*(.rela.bss)
/* *(.rel.bss)
*(.rela.bss) */
}
/* . = ALIGN(0x1000); */
. = ALIGN(0x1000);
_end = . ;
.prgtrailer : {
LONG(0) /* FIXUP OFFSET */
LONG(0)
@ -62,3 +71,4 @@ SECTIONS
/* Strip unnecessary stuff */
/DISCARD/ : { *(.comment .note .eh_frame) }
}

View File

@ -44,9 +44,8 @@
//.text
_bs_entry:
/* main entry point, both from the floppy boot and .prg */
//bra.s skip_fat_skim
bra.s real_entry
//bra.s _bs_entry
//FAT lookalike to avoid nasty things from happening
// http://alive.atari.org/alive10/btmania.php
.ascii "Haiku0"
@ -58,7 +57,7 @@ _bs_entry:
.byte 0x00, 0x02 //RES - number of reserved sectors
.byte 0x00//0x02 //NFATS
.byte 0x00/*70*/, 0x00 //NDIRS
.byte 0x00, 0x02 //NSECTS
.byte 0xa0, 0x05 //NSECTS
.byte 0xf8 //MEDIA
.byte 0x05, 0x00 //SPF
.byte 0x09, 0x00 //SPT
@ -66,46 +65,38 @@ _bs_entry:
.byte 0x00, 0x00 //NHID
// we're done
skip_fat_skim:
// lea str,%a0
// bsr puts
// bra skip_fat_skim
//rts
// bra real_entry
sNumSectors:
// this location will contain the length of the boot loader as
// written by the "makeflop" command in 512 byte blocks
// 0x180 is the allowed maximum, as the zipped TAR with the
// kernel and the boot module might start at offset 192 kB
.word 0x0180
.word 0x0300 //0x0180
real_entry:
#if 0
lea h1,%a0
bsr puts
move.l #0x1234aa55,%d0
bsr putx
#endif
#if 0
//_membot
move.l #0x432,%a0
move.l (%a0),%d0
bsr putx
//move.l #0x432,%a0
//move.l (%a0),%d0
//bsr putx
//_memtop
move.l #0x436,%a0
move.l (%a0),%d0
bsr putx
//move.l #0x436,%a0
//move.l (%a0),%d0
//bsr putx
//_v_bas_ad
move.l #0x44e,%a0
move.l (%a0),%d0
bsr putx
//Pterm0
//move.w #0,-(%sp)
//trap #1
#endif
// first, determine if .prg (user) or bootsect (super)
// Super()
@ -123,7 +114,11 @@ real_entry:
bra prg_start
//bra bootsect_start
rts
/*
* floppy boot support code
*/
floppy_start:
lea h3,%a0
bsr puts
@ -136,9 +131,11 @@ floppy_start:
// load the rest
move.w sNumSectors,%d2
// load at base + this code.
move.l #ATARI_ZBEOS_BASE+512,%a2
move.l #(ATARI_ZBEOS_BASE+512),%a2
//move.l %a2,%d0
//bsr putx
bsr load_sectors
tst.l %d0
tst.w %d0
beq floppy_done
lea failure_string,%a0
bsr puts
@ -150,6 +147,7 @@ floppy_done:
move.l #ATARI_ZBEOS_STACK_BASE,%sp
lea h5,%a0
bsr puts
move.l #0,%d0
//jmp ATARI_ZBEOS_BASE+512
jmp _start
@ -161,15 +159,40 @@ floppy_done:
load_sectors:
#if 1
/* it seems to skip 9 every 9 sectors, buggy side handling ? */
// Rwabs
//move.l #1,-(%sp)
move.w #0,-(%sp) // A:
//move.w #2,-(%sp) // C:
//move.w #-1,-(%sp) // 2nd sector
move.w #1,-(%sp) // 2nd sector
move.w %d2,-(%sp)
move.l %a2,-(%sp)
move.w #RW_READ+RW_NOTRANSLATE,-(%sp)
//move.w #RW_READ+RW_NOTRANSLATE,-(%sp)
move.w #RW_READ+RW_NOMEDIACH,-(%sp)
move.w #4,-(%sp)
trap #13
add.l #14,%sp
#endif
#if 0
// d2:
//move.w %d2,-(%sp)
move.w #9,-(%sp)
move.w #0,-(%sp)
move.w #0,-(%sp)
move.w #1,-(%sp)
move.w #0,-(%sp)
move.l #0,-(%sp)
//move.w #0,-(%sp)
//move.l %a2,-(%sp)
move.l #ATARI_ZBEOS_BASE,-(%sp)
move.w #8,-(%sp) // floprd
trap #XBIOS_TRAP
add.l #20,%sp
#endif
bsr putx
rts
@ -181,18 +204,14 @@ failure_string:
// .org DOT_STRING
.string "."
//shell_end:
// .skip 0x01fe - tmp_floppy_end
//// .org 0x01fe
// .word 0xaa55
// this bumps the "start" label to offset 0x0200 as
// expected by the BFS boot loader, and also marks
// this block as valid boot block for the BIOS
/*
* \AUTO\HAIKU.PRG and ARAnyM BOOTSTRAP() support code
*/
prg_start:
lea h4,%a0
bsr puts
#if 0
//lea h4,%a0
//bsr puts
// .prg:
// we need to switch to supervisor mode anyway
move.l #SUP_SET,-(%sp)
@ -200,12 +219,12 @@ prg_start:
trap #1
addq.l #6,%sp
move.l %d0,saved_super_stack
// disable interrupts
or.w #0x0700,%sr
lea h5,%a0
bsr puts
//Pterm0
move.w #0,-(%sp)
trap #1
// copy the rest of the prg
move.l sNumSectors,%d0
@ -219,18 +238,16 @@ copysect_loop:
move.l (%a0)+,(%a1)+
dbf %d1,copysect_loop
dbf %d0,nextsect
#endif
lea str,%a0
lea msg_j1,%a0
bsr puts
// all done
spin:
lea unimpl,%a0
bsr puts
bra spin
//bra spin
super_done:
// XXX: copy the rest !
move.l #0,%d0
//jmp ATARI_ZBEOS_BASE+512
jmp _start
@ -322,6 +339,8 @@ h5:
.string "H5"
unimpl:
.string "Unimplemented."
msg_j1:
.string "jumping to zbeos."
shell_end:

View File

@ -43,7 +43,7 @@ clear_bss(void)
static void
call_ctors(void)
{
{
void (**f)(void);
for (f = &__ctor_list; f < &__ctor_end; f++) {
@ -108,11 +108,6 @@ void
_start(void)
{
stage2_args args;
Bconout(DEV_CON, 'h');
Bconout(DEV_CON, 'A');
Bconout(DEV_CON, 'I');
Bconout(DEV_CON, 'K');
Bconout(DEV_CON, 'U');
//asm("cld"); // Ain't nothing but a GCC thang.
@ -127,7 +122,7 @@ _start(void)
//serial_init();
console_init();
cpu_init();
mmu_init();
//mmu_init();
// wait a bit to give the user the opportunity to press a key
spin(750000);

View File

@ -209,17 +209,25 @@ struct tosbpb {
#define Kbshift(mode) toscallW(BIOS_TRAP, 11, (uint16)mode)
/* handy shortcut */
static inline int Bconputs(int16 handle, const char *string)
static inline int Bconput(int16 handle, const char *string)
{
int i, err;
for (i = 0; string[i]; i++) {
if (string[i] == '\n')
Bconout(handle, '\r');
err = Bconout(handle, string[i]);
if (err < 0)
break;
}
return i;
}
static inline int Bconputs(int16 handle, const char *string)
{
int err = Bconput(handle, string);
Bconout(handle, '\r');
Bconout(handle, '\n');
return i;
return err;
}
#endif /* __ASSEMBLER__ */
@ -310,6 +318,7 @@ static inline int Bconputs(int16 handle, const char *string)
*/
extern status_t toserror(int32 err);
extern void dump_tos_cookies(void);
/*
* Cookie Jar access