* Fixes
* More test code * it actually runs now, till _start. However, calling TOS from C is broken: we use 32 bit param alignment on funcs, but TOS expects 16 bit... need to use asm macros instead of funcs. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23531 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -21,7 +21,7 @@
|
|||||||
#define ATARI_SHADOW_BASE 0xff000000
|
#define ATARI_SHADOW_BASE 0xff000000
|
||||||
|
|
||||||
/* how we will use it */
|
/* how we will use it */
|
||||||
#define ATARI_ZBEOS_STACK_BASE 0x00008000
|
#define ATARI_ZBEOS_STACK_BASE 0x00040000
|
||||||
#define ATARI_ZBEOS_BASE 0x00010000 /* from .prg shell.S will copy itself there */
|
#define ATARI_ZBEOS_BASE 0x00080000 /* from .prg shell.S will copy itself there */
|
||||||
|
|
||||||
#endif /* ATARI_MEMORY_MAP_H */
|
#endif /* ATARI_MEMORY_MAP_H */
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ int main(int argc, char **argv)
|
|||||||
v += *p++;
|
v += *p++;
|
||||||
sum += v;
|
sum += v;
|
||||||
}
|
}
|
||||||
sum = 0x1234 - sum + 1;
|
sum = 0x1234 - sum /*+ 1*/;
|
||||||
//sum = 0xaa55;
|
//sum = 0xaa55;
|
||||||
// big endian
|
// big endian
|
||||||
*p++ = (uint8_t)(sum >> 8);
|
*p++ = (uint8_t)(sum >> 8);
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ struct boot_mmu_ops {
|
|||||||
/* len=0 to disable */
|
/* len=0 to disable */
|
||||||
status_t (*set_tt)(int which, addr_t pa, size_t len, uint32 perms);
|
status_t (*set_tt)(int which, addr_t pa, size_t len, uint32 perms);
|
||||||
/* load root pointers */
|
/* load root pointers */
|
||||||
status_t (*load_rp)(XXX);
|
status_t (*load_rp)(void/*XXX*/);
|
||||||
status_t (*enable_paging)(void);
|
status_t (*enable_paging)(void);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -81,30 +81,57 @@ sNumSectors:
|
|||||||
.word 0x0180
|
.word 0x0180
|
||||||
|
|
||||||
real_entry:
|
real_entry:
|
||||||
|
lea h1,%a0
|
||||||
|
bsr puts
|
||||||
|
move.l #0x1234aa55,%d0
|
||||||
|
bsr putx
|
||||||
|
|
||||||
|
|
||||||
|
//_membot
|
||||||
|
move.l #0x432,%a0
|
||||||
|
move.l (%a0),%d0
|
||||||
|
bsr putx
|
||||||
|
|
||||||
|
//_memtop
|
||||||
|
move.l #0x436,%a0
|
||||||
|
move.l (%a0),%d0
|
||||||
|
bsr putx
|
||||||
|
|
||||||
|
//_v_bas_ad
|
||||||
|
move.l #0x44e,%a0
|
||||||
|
move.l (%a0),%d0
|
||||||
|
bsr putx
|
||||||
|
|
||||||
|
|
||||||
//Pterm0
|
//Pterm0
|
||||||
//move.w #1,%d0
|
//move.w #0,-(%sp)
|
||||||
//trap #1
|
//trap #1
|
||||||
|
|
||||||
// first, determine if .prg (user) or bootsect (super)
|
// first, determine if .prg (user) or bootsect (super)
|
||||||
// Super()
|
// Super()
|
||||||
move.l #SUP_INQUIRE,-(%sp)
|
move.l #SUP_INQUIRE,-(%sp)
|
||||||
move.w #0x20,%d0
|
move.w #0x20,-(%sp)
|
||||||
trap #1
|
trap #1
|
||||||
addq.l #6,%sp
|
addq.l #6,%sp
|
||||||
cmp.w #SUP_SUPER,%d0
|
|
||||||
beq floppy_start
|
bsr putx
|
||||||
|
|
||||||
|
cmp.l #SUP_USER,%d0
|
||||||
|
bne floppy_start
|
||||||
|
lea h2,%a0
|
||||||
|
bsr puts
|
||||||
|
|
||||||
bra prg_start
|
bra prg_start
|
||||||
//bra bootsect_start
|
//bra bootsect_start
|
||||||
rts
|
rts
|
||||||
floppy_start:
|
floppy_start:
|
||||||
|
lea h3,%a0
|
||||||
|
bsr puts
|
||||||
lea str,%a0
|
lea str,%a0
|
||||||
bsr puts
|
bsr puts
|
||||||
bra floppy_start
|
//bra floppy_start
|
||||||
// no interrupt
|
// no interrupt
|
||||||
and.w #0x0700,%sr
|
or.w #0x0700,%sr
|
||||||
// setup stack
|
|
||||||
move.l #ATARI_ZBEOS_STACK_BASE,%sp
|
|
||||||
//XXX: check for enough RAM
|
//XXX: check for enough RAM
|
||||||
// load the rest
|
// load the rest
|
||||||
move.w sNumSectors,%d2
|
move.w sNumSectors,%d2
|
||||||
@@ -117,7 +144,14 @@ floppy_start:
|
|||||||
bsr puts
|
bsr puts
|
||||||
bra spin
|
bra spin
|
||||||
floppy_done:
|
floppy_done:
|
||||||
jmp ATARI_ZBEOS_BASE+512
|
lea h4,%a0
|
||||||
|
bsr puts
|
||||||
|
// setup stack
|
||||||
|
move.l #ATARI_ZBEOS_STACK_BASE,%sp
|
||||||
|
lea h5,%a0
|
||||||
|
bsr puts
|
||||||
|
//jmp ATARI_ZBEOS_BASE+512
|
||||||
|
jmp _start
|
||||||
|
|
||||||
//rts
|
//rts
|
||||||
|
|
||||||
@@ -136,12 +170,13 @@ load_sectors:
|
|||||||
move.w #4,-(%sp)
|
move.w #4,-(%sp)
|
||||||
trap #13
|
trap #13
|
||||||
add.l #14,%sp
|
add.l #14,%sp
|
||||||
|
bsr putx
|
||||||
rts
|
rts
|
||||||
|
|
||||||
floppy_end:
|
floppy_end:
|
||||||
// .org FAILURE_STRING
|
// .org FAILURE_STRING
|
||||||
failure_string:
|
failure_string:
|
||||||
.string " Loading failed! Press key to reboot.\r\n"
|
// .string " Loading failed! Press key to reboot.\r\n"
|
||||||
|
|
||||||
// .org DOT_STRING
|
// .org DOT_STRING
|
||||||
.string "."
|
.string "."
|
||||||
@@ -155,22 +190,49 @@ failure_string:
|
|||||||
// this block as valid boot block for the BIOS
|
// this block as valid boot block for the BIOS
|
||||||
|
|
||||||
prg_start:
|
prg_start:
|
||||||
|
lea h4,%a0
|
||||||
|
bsr puts
|
||||||
|
#if 0
|
||||||
// .prg:
|
// .prg:
|
||||||
// we need to switch to supervisor mode anyway
|
// we need to switch to supervisor mode anyway
|
||||||
move.l #SUP_SET,-(%sp)
|
move.l #SUP_SET,-(%sp)
|
||||||
move.w #0x20,%d0
|
move.w #0x20,-(%sp)
|
||||||
trap #1
|
trap #1
|
||||||
addq.l #6,%sp
|
addq.l #6,%sp
|
||||||
move.l %d0,saved_super_stack
|
move.l %d0,saved_super_stack
|
||||||
|
|
||||||
|
lea h5,%a0
|
||||||
|
bsr puts
|
||||||
|
//Pterm0
|
||||||
|
move.w #0,-(%sp)
|
||||||
|
trap #1
|
||||||
|
|
||||||
|
// copy the rest of the prg
|
||||||
|
move.l sNumSectors,%d0
|
||||||
|
sub.l #1,%d0
|
||||||
|
lea _bs_entry,%a0
|
||||||
|
move.l #ATARI_ZBEOS_BASE,%a1
|
||||||
|
|
||||||
|
nextsect:
|
||||||
|
move.l #512/4-1,%d1
|
||||||
|
copysect_loop:
|
||||||
|
move.l (%a0)+,(%a1)+
|
||||||
|
dbf %d1,copysect_loop
|
||||||
|
dbf %d0,nextsect
|
||||||
|
#endif
|
||||||
|
|
||||||
|
lea str,%a0
|
||||||
|
bsr puts
|
||||||
// all done
|
// all done
|
||||||
|
spin:
|
||||||
lea unimpl,%a0
|
lea unimpl,%a0
|
||||||
bsr puts
|
bsr puts
|
||||||
spin:
|
|
||||||
bra spin
|
bra spin
|
||||||
|
|
||||||
super_done:
|
super_done:
|
||||||
// XXX: copy the rest !
|
// XXX: copy the rest !
|
||||||
jmp ATARI_ZBEOS_BASE+512
|
//jmp ATARI_ZBEOS_BASE+512
|
||||||
|
jmp _start
|
||||||
|
|
||||||
saved_super_stack:
|
saved_super_stack:
|
||||||
.long 0
|
.long 0
|
||||||
@@ -186,6 +248,33 @@ GLOBAL(gBootPartitionOffset):
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
putx:
|
||||||
|
movem.l %d0-%d2/%a0-%a2,-(%sp)
|
||||||
|
move.l #8-1,%d2
|
||||||
|
move.l %d0,%d1
|
||||||
|
putxloop:
|
||||||
|
move.l %d1,%d0
|
||||||
|
lsl.l #4,%d1
|
||||||
|
//swap %d0
|
||||||
|
//lsr.l #8,%d0
|
||||||
|
//lsr.l #4,%d0
|
||||||
|
rol.l #4,%d0
|
||||||
|
and.l #0x0f,%d0
|
||||||
|
cmp.b #9,%d0
|
||||||
|
ble putx0
|
||||||
|
add.b #'a'-'0'-10,%d0
|
||||||
|
//bra putxdisp
|
||||||
|
putx0:
|
||||||
|
add.b #'0',%d0
|
||||||
|
putxdisp:
|
||||||
|
bsr putc
|
||||||
|
dbf %d2,putxloop
|
||||||
|
move.b #'\r',%d0
|
||||||
|
bsr putc
|
||||||
|
move.b #'\n',%d0
|
||||||
|
bsr putc
|
||||||
|
movem.l (%sp)+,%d0-%d2/%a0-%a2
|
||||||
|
rts
|
||||||
|
|
||||||
lea.l str,%a0
|
lea.l str,%a0
|
||||||
puts:
|
puts:
|
||||||
@@ -195,10 +284,10 @@ puts:
|
|||||||
bsr putc
|
bsr putc
|
||||||
bra .loopt
|
bra .loopt
|
||||||
.strout:
|
.strout:
|
||||||
//Pterm0
|
move.b #'\r',%d0
|
||||||
move.w #1,%d0
|
bsr putc
|
||||||
trap #1
|
move.b #'\n',%d0
|
||||||
|
bsr putc
|
||||||
rts
|
rts
|
||||||
|
|
||||||
.loop:
|
.loop:
|
||||||
@@ -207,21 +296,34 @@ puts:
|
|||||||
bra .loop
|
bra .loop
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
|
||||||
/* prints the char in d0.b to the console */
|
/* prints the char in d0.b to the console */
|
||||||
putc:
|
putc:
|
||||||
movem.l %a0,-(%sp)
|
movem.l %d0-%d2/%a0-%a2,-(%sp)
|
||||||
move.w %d0,-(%sp)
|
move.w %d0,-(%sp)
|
||||||
move.w #DEV_CON,-(%sp) // DEV_CON
|
move.w #DEV_CON,-(%sp) // DEV_CON
|
||||||
move.w #3,-(%sp) // Bconout
|
move.w #3,-(%sp) // Bconout
|
||||||
trap #13
|
trap #13
|
||||||
add.l #6,%sp
|
add.l #6,%sp
|
||||||
movem.l (%sp)+,%a0
|
movem.l (%sp)+,%d0-%d2/%a0-%a2
|
||||||
rts
|
rts
|
||||||
|
|
||||||
str:
|
str:
|
||||||
.string "Haiku!"
|
.string "Haiku!"
|
||||||
|
h1:
|
||||||
|
.string "H1"
|
||||||
|
h2:
|
||||||
|
.string "H2"
|
||||||
|
h3:
|
||||||
|
.string "H3"
|
||||||
|
h4:
|
||||||
|
.string "H4"
|
||||||
|
h5:
|
||||||
|
.string "H5"
|
||||||
unimpl:
|
unimpl:
|
||||||
.string "Unimplemented."
|
.string "Unimplemented."
|
||||||
|
|
||||||
|
|
||||||
shell_end:
|
shell_end:
|
||||||
//.fill (0x01fe - shell_end), 1, 0x55
|
//.fill (0x01fe - shell_end), 1, 0x55
|
||||||
.org 0x01fe
|
.org 0x01fe
|
||||||
|
|||||||
@@ -108,6 +108,12 @@ void
|
|||||||
_start(void)
|
_start(void)
|
||||||
{
|
{
|
||||||
stage2_args args;
|
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.
|
//asm("cld"); // Ain't nothing but a GCC thang.
|
||||||
//asm("fninit"); // initialize floating point unit
|
//asm("fninit"); // initialize floating point unit
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ extern "C" {
|
|||||||
|
|
||||||
#ifndef __ASSEMBLER__
|
#ifndef __ASSEMBLER__
|
||||||
#include <OS.h>
|
#include <OS.h>
|
||||||
#endif
|
#endif /* __ASSEMBLER__ */
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Atari BIOS calls
|
* Atari BIOS calls
|
||||||
@@ -169,7 +170,7 @@ extern int32 gemdos(uint16 nr, ...);
|
|||||||
|
|
||||||
#endif /* __ASSEMBLER__ */
|
#endif /* __ASSEMBLER__ */
|
||||||
|
|
||||||
#ifdef __ASSEMBLER__
|
#ifndef __ASSEMBLER__
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* error mapping
|
* error mapping
|
||||||
@@ -243,6 +244,8 @@ static inline const struct tos_osheader *tos_get_osheader()
|
|||||||
#define NF_COOKIE 0x5f5f4e46L //'__NF'
|
#define NF_COOKIE 0x5f5f4e46L //'__NF'
|
||||||
#define NF_MAGIC 0x20021021L
|
#define NF_MAGIC 0x20021021L
|
||||||
|
|
||||||
|
#ifndef __ASSEMBLER__
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
long magic;
|
long magic;
|
||||||
long (*nfGetID) (const char *);
|
long (*nfGetID) (const char *);
|
||||||
@@ -253,14 +256,18 @@ extern NatFeatCookie *gNatFeatCookie;
|
|||||||
|
|
||||||
static inline NatFeatCookie *nat_features(void)
|
static inline NatFeatCookie *nat_features(void)
|
||||||
{
|
{
|
||||||
|
const struct tos_cookie *c;
|
||||||
if (gNatFeatCookie == (void *)-1 || !gNatFeatCookie)
|
if (gNatFeatCookie == (void *)-1 || !gNatFeatCookie)
|
||||||
return NULL;
|
return NULL;
|
||||||
gNatFeatCookie = tos_find_cookie(NF_COOKIE);
|
c = tos_find_cookie(NF_COOKIE);
|
||||||
if (!gNatFeatCookie || gNatFeatCookie->magic != NF_MAGIC) {
|
if (c) {
|
||||||
gNatFeatCookie = (void *)-1;
|
gNatFeatCookie = (NatFeatCookie *)c->pvalue;
|
||||||
return NULL;
|
if (gNatFeatCookie && gNatFeatCookie->magic == NF_MAGIC) {
|
||||||
|
return gNatFeatCookie;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return c;
|
gNatFeatCookie = (NatFeatCookie *)-1;
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -269,21 +276,15 @@ static inline NatFeatCookie *nat_features(void)
|
|||||||
#define NF_XHDI "XHDI"
|
#define NF_XHDI "XHDI"
|
||||||
|
|
||||||
#define nfxhdi(code, a...) \
|
#define nfxhdi(code, a...) \
|
||||||
{ \
|
({ \
|
||||||
gNatFeatCookie->nfCall((uint32)
|
gNatFeatCookie->nfCall((uint32)code, a##...); \
|
||||||
if (gNatFeatCookie == NULL) {
|
})
|
||||||
c = tos_find_cookie(NF_COOKIE);
|
|
||||||
if (!c || c->magic != NF_MAGIC)
|
|
||||||
return NULL;
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#define NFXHversion() nfxhdi(0)
|
#define NFXHversion() nfxhdi(0)
|
||||||
|
|
||||||
#endif /* __ASSEMBLER__ */
|
#endif /* __ASSEMBLER__ */
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user