- Add some useful TOS variables.

- Spice up cpu and machine detection.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26086 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
François Revol 2008-06-22 21:23:36 +00:00
parent 375be9fa40
commit 1654ce1468
2 changed files with 71 additions and 8 deletions

View File

@ -39,10 +39,12 @@ check_cpu_features()
const tos_cookie *c;
uint16 cpu_type, fpu_type, fpu_emul;
uint16 machine_type;
int fpu;
c = tos_find_cookie('_CPU');
if (!c) {
panic("can't get a cookie (_CPU)! Mum, I'm hungry!");
panic("can't get a cookie (_CPU)!");
return EINVAL;
}
cpu_type = (uint16) c->ivalue;
@ -53,23 +55,45 @@ check_cpu_features()
if (cpu_type < 30/*20*/)
return EINVAL;
#warning M68K: check cpu type passed to kern args
gKernelArgs.arch_args.cpu_type = 68000 + cpu_type;
gKernelArgs.arch_args.mmu_type = 68000 + cpu_type;
gKernelArgs.arch_args.has_lpstop = (cpu_type >= 60)?true:false;
#warning M68K: add cpu type to kern args
c = tos_find_cookie('_FPU');
if (!c) {
panic("can't get a cookie (_FPU)! Mum, I'm hungry!");
panic("can't get a cookie (_FPU)!");
return EINVAL;
}
fpu_type = (uint16)(c->ivalue >> 16);
fpu_emul = (uint16)(c->ivalue);
#warning M68K: check for fpu in detail
// CT060 seems to use 16...
if (fpu_type < 2 || fpu_type > 16) {
// http://toshyp.atari.org/003007.htm#Cookie_2C_20_FPU
if (fpu_type & 0x10)
fpu = 68060;
else if (fpu_type & 0x8)
fpu = 68040;
else if (fpu_type & 0x6 == 0x6)
fpu = 68882;
else if (fpu_type & 0x6 == 0x4)
fpu = 68881;
else if (fpu_type & 0x6 == 0x2)
fpu = 68881; // not certain
else if (fpu_type & 0x4) {
panic("bad fpu");
return EINVAL;
}
gKernelArgs.arch_args.fpu_type = fpu;
gKernelArgs.arch_args.platform = M68K_PLATFORM_ATARI;
c = tos_find_cookie('_MCH');
if (!c) {
panic("can't get a cookie (_MCH)!");
return EINVAL;
}
machine_type = (uint16)(c->ivalue >> 16);
gKernelArgs.arch_args.platform = machine_type;
return B_OK;
}
@ -79,7 +103,9 @@ static bigtime_t gSystemTimeCounter = 0; //HACK
extern "C" bigtime_t
system_time(void)
{
return gSystemTimeCounter++;
// _hz_200
return (*TOSVAR_hz_200) * 1000000LL / 200;
//return gSystemTimeCounter++;
}

View File

@ -144,6 +144,43 @@ extern "C" {
#endif /* __ASSEMBLER__ */
#ifdef __ASSEMBLER__
#define _TOSV_P(a) a
#define _TOSV_L(a) a
#define _TOSV_W(a) a
#define _TOSV_B(a) a
#else
#define _TOSV_P(a) ((void **)a)
#define _TOSV_L(a) ((uint32 *)a)
#define _TOSV_W(a) ((uint16 *)a)
#define _TOSV_B(a) ((uint8 *)a)
#endif
/*
* TOS Variables
* only relevant ones,
* see toshyp.atari.org/003004.htm
*/
#define TOSVAR_autopath _TOSV_P(0x4ca)
#define TOSVAR_bootdev _TOSV_W(0x446)
#define TOSVAR_dskbufp _TOSV_P(0x4c6)
#define TOSVAR_drvbits _TOSV_L(0x4c2)
#define TOSVAR_frclock _TOSV_L(0x466)
#define TOSVAR_hz_200 _TOSV_L(0x4ba)
#define TOSVAR_membot _TOSV_L(0x432)
#define TOSVAR_memtop _TOSV_L(0x436)
#define TOSVAR_nflops _TOSV_W(0x4a6)
#define TOSVAR_p_cookies _TOSV_P(0x5A0)
#define TOSVAR_sysbase _TOSV_P(0x4f2)
#define TOSVAR_timr_ms _TOSV_W(0x442)
#define TOSVAR_v_bas_ad _TOSV_P(0x44e)
#define TOSVAR_vbclock _TOSV_L(0x462)
#define TOSVARphystop _TOSV_L(0x42e)
#define TOSVARramtop _TOSV_L(0x5a4)
#define TOSVARramvalid _TOSV_(0x5a8)
#define TOSVARramvalid_MAGIC 0x1357bd13
#define BIOS_TRAP 13
#define XBIOS_TRAP 14
#define GEMDOS_TRAP 1
@ -626,7 +663,7 @@ typedef struct tos_cookie {
};
} tos_cookie;
#define COOKIE_JAR (*((const tos_cookie **)0x5A0))
#define COOKIE_JAR (*((const tos_cookie **)TOSVAR_p_cookies))
static inline const tos_cookie *tos_find_cookie(uint32 what)
{