From 9175cb7ce6569dd8de8831f144952055f182eebb Mon Sep 17 00:00:00 2001 From: sonic Date: Mon, 4 Oct 2010 06:30:18 +0000 Subject: [PATCH] Merged exec init code git-svn-id: https://svn.aros.org/svn/aros/trunk/AROS@34575 fb15a70f-31f2-0310-bbcc-cdcc74a49acc --- arch/all-mingw32/exec/exec_init.c | 355 ------------------------------------ arch/all-mingw32/exec/idletask.c | 7 - arch/all-mingw32/exec/mmakefile.src | 4 +- arch/all-unix/kernel/kernel.c | 7 + rom/exec/exec_init.c | 29 --- 5 files changed, 9 insertions(+), 393 deletions(-) delete mode 100644 arch/all-mingw32/exec/exec_init.c delete mode 100644 arch/all-mingw32/exec/idletask.c diff --git a/arch/all-mingw32/exec/exec_init.c b/arch/all-mingw32/exec/exec_init.c deleted file mode 100644 index ceac91366a..0000000000 --- a/arch/all-mingw32/exec/exec_init.c +++ /dev/null @@ -1,355 +0,0 @@ -/* - Copyright 1995-2010, The AROS Development Team. All rights reserved. - $Id$ - - Desc: exec.library resident and initialization. - Lang: english -*/ -#define DEBUG 0 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include -#include -#include -#include /* need ABS() */ - -#include "exec_intern.h" -#include "exec_util.h" -#include "etask.h" -#include LC_LIBDEFS_FILE - -static const UBYTE name[]; -static const UBYTE version[]; -extern const char LIBEND; -AROS_UFP3(LIBBASETYPEPTR, GM_UNIQUENAME(init), - AROS_UFPA(ULONG, dummy, D0), - AROS_UFPA(BPTR, segList, A0), - AROS_UFPA(struct ExecBase *, sysBase, A6)); - - -const struct Resident Exec_resident = -{ - RTC_MATCHWORD, - (struct Resident *)&Exec_resident, - (APTR)&LIBEND, - RTF_SINGLETASK, - VERSION_NUMBER, - NT_LIBRARY, - 105, - (STRPTR)name, - (STRPTR)&version[6], - &GM_UNIQUENAME(init) -}; - -static const UBYTE name[] = MOD_NAME_STRING; -static const UBYTE version[] = VERSION_STRING; - -extern void debugmem(void); - -/* - We temporarily redefine kprintf() so we use the real version in case - we have one of these two fn's called before AROSSupportBase is ready. -*/ - -#undef kprintf -#undef rkprintf -#undef vkprintf -struct Library * PrepareAROSSupportBase (struct ExecBase * SysBase) -{ - struct AROSSupportBase * AROSSupportBase; - AROSSupportBase = AllocMem(sizeof(struct AROSSupportBase), MEMF_CLEAR); - AROSSupportBase->kprintf = (void *)kprintf; - AROSSupportBase->rkprintf = (void *)rkprintf; - AROSSupportBase->vkprintf = (void *)vkprintf; - NEWLIST(&AROSSupportBase->AllocMemList); - -#warning FIXME Add code to read in the debug options - - return (struct Library *)AROSSupportBase; -} - -void _aros_not_implemented(char *X) -{ - kprintf("Unsupported function at offset -0x%h in %s\n", - ABS(*(WORD *)((&X)[-1]-2)), - ((struct Library *)(&X)[-2])->lib_Node.ln_Name); -} -#define kprintf (((struct AROSSupportBase *)(SysBase->DebugAROSBase))->kprintf) -#define rkprintf (((struct AROSSupportBase *)(SysBase->DebugAROSBase))->rkprintf) -#define vkprintf (((struct AROSSupportBase *)(SysBase->DebugAROSBase))->vkprintf) - -/* IntServer: - This interrupt handler will send an interrupt to a series of queued - interrupt servers. Servers should return D0 != 0 (Z clear) if they - believe the interrupt was for them, and no further interrupts will - be called. This will only check the value in D0 for non-m68k systems, - however it SHOULD check the Z-flag on 68k systems. - - Hmm, in that case I would have to separate it from this file in order - to replace it... -*/ -AROS_UFH5S(void, IntServer, - AROS_UFHA(ULONG, intMask, D0), - AROS_UFHA(struct Custom *, custom, A0), - AROS_UFHA(struct List *, intList, A1), - AROS_UFHA(APTR, intCode, A5), - AROS_UFHA(struct ExecBase *, SysBase, A6)) -{ - AROS_USERFUNC_INIT - - struct Interrupt * irq; - - ForeachNode(intList, irq) - { - if( AROS_UFC4(int, irq->is_Code, - AROS_UFCA(struct Custom *, custom, A0), - AROS_UFCA(APTR, irq->is_Data, A1), - AROS_UFCA(APTR, irq->is_Code, A5), - AROS_UFCA(struct ExecBase *, SysBase, A6) - )) - break; - } - - AROS_USERFUNC_EXIT -} - -/* VBlankServer. The same as general purpose IntServer but also counts task's quantum */ -AROS_UFH5S(void, VBlankServer, - AROS_UFHA(ULONG, intMask, D1), - AROS_UFHA(struct Custom *, custom, A0), - AROS_UFHA(struct List *, intList, A1), - AROS_UFHA(APTR, intCode, A5), - AROS_UFHA(struct ExecBase *, SysBase, A6)) -{ - AROS_USERFUNC_INIT - - struct Interrupt *irq; - - /* First decrease Elapsed time for current task */ - if (SysBase->Elapsed && (--SysBase->Elapsed == 0)) - { - SysBase->SysFlags |= SFF_QuantumOver; - SysBase->AttnResched |= ARF_AttnSwitch; - } - - ForeachNode(intList, irq) - { - if( AROS_UFC4(int, irq->is_Code, - AROS_UFCA(struct Custom *, custom, A0), - AROS_UFCA(APTR, irq->is_Data, A1), - AROS_UFCA(APTR, irq->is_Code, A5), - AROS_UFCA(struct ExecBase *, SysBase, A6) - )) - break; - } - - AROS_USERFUNC_EXIT -} - -extern ULONG SoftIntDispatch(); - -AROS_UFH3(LIBBASETYPEPTR, GM_UNIQUENAME(init), - AROS_UFHA(ULONG, dummy, D0), - AROS_UFHA(BPTR, segList, A0), - AROS_UFHA(struct ExecBase *, sysBase, A6) -) -{ - AROS_USERFUNC_INIT - - struct Task *t; - struct MemList *ml; - int i, j; - UWORD sum; - UWORD *ptr; - - SysBase = sysBase; - - KernelBase = OpenResource("kernel.resource"); - D(bug("[exec_init] KernelBase is 0x%p\n", KernelBase)); - if (!KernelBase) - return NULL; - - /* We print the notice here because kprintf() works only after KernelBase is set up */ - if (PrivExecBase(SysBase)->IntFlags & EXECF_MungWall) - bug("[exec] Mungwall enabled\n"); - - /* - Create boot task. Sigh, we actually create a Process sized Task, - since DOS needs to call things which think it has a Process and - we don't want to overwrite memory with something strange do we? - - We do this until at least we can boot dos more cleanly. - */ - - ml = (struct MemList *)AllocMem(sizeof(struct MemList), MEMF_PUBLIC|MEMF_CLEAR); - t = (struct Task *) AllocMem(sizeof(struct Process), MEMF_PUBLIC|MEMF_CLEAR); - if( !ml || !t ) { - kprintf("ERROR: Cannot create Boot Task!\n"); - Alert( AT_DeadEnd | AG_NoMemory | AN_ExecLib ); - } - - ml->ml_NumEntries = 1; - ml->ml_ME[0].me_Addr = t; - ml->ml_ME[0].me_Length = sizeof(struct Process); - - NEWLIST(&t->tc_MemEntry); - NEWLIST(&((struct Process *)t)->pr_MsgPort.mp_MsgList); - - /* It's the boot process that RunCommand()s the boot shell, so we - must have this list initialized */ - NEWLIST((struct List *)&((struct Process *)t)->pr_LocalVars); - - AddHead(&t->tc_MemEntry,&ml->ml_Node); - - t->tc_Node.ln_Name = "Boot Task"; - t->tc_Node.ln_Pri = 0; - t->tc_State = TS_RUN; - t->tc_SigAlloc = 0xFFFF; - t->tc_SPLower = 0; /* This is the system's stack */ - t->tc_SPUpper = (APTR)~0UL; - t->tc_Flags |= TF_ETASK; - - t->tc_UnionETask.tc_ETask = AllocVec(sizeof(struct IntETask), MEMF_ANY|MEMF_CLEAR); - if (!t->tc_UnionETask.tc_ETask) { - kprintf("Not enough memory for first task\n"); - Alert( AT_DeadEnd | AG_NoMemory | AN_ExecLib ); - } - - /* Initialise the ETask data. */ - InitETask(t, t->tc_UnionETask.tc_ETask); - - GetIntETask(t)->iet_Context = KrnCreateContext(); - if (!GetIntETask(t)->iet_Context) { - kprintf("Not enough memory for first task\n"); - Alert( AT_DeadEnd | AG_NoMemory | AN_ExecLib ); - } - - sysBase->ThisTask = t; - sysBase->Elapsed = sysBase->Quantum; - - D(bug("[exec_init] Installing interrupt servers\n")); - /* Install the interrupt servers */ - for(i=0; i < 16; i++) - { - struct Interrupt *is; - - if( (1<is_Code = &VBlankServer; - else - is->is_Code = &IntServer; - is->is_Data = sil; - NEWLIST((struct List *)sil); - SetIntVector(i,is); - } - else - { - struct Interrupt * is; - - switch(i) { - case INTB_SOFTINT: - is = AllocMem(sizeof(struct Interrupt), MEMF_CLEAR|MEMF_PUBLIC); - if (NULL == is) { - kprintf("Error: Cannot install SoftInt Handler!\n"); - Alert( AT_DeadEnd | AN_IntrMem ); - } - - is->is_Node.ln_Type = NT_INTERRUPT; - is->is_Node.ln_Pri = 0; - is->is_Node.ln_Name = "SW Interrupt Dispatcher"; - is->is_Data = NULL; - is->is_Code = (void *)SoftIntDispatch; - SetIntVector(i,is); - break; - } - } - } - - /* We now start up the interrupts */ - Permit(); - Enable(); - - /* Now it's time to calculate exec checksum. It will be used - * in future to distinguish whether we'd had proper execBase - * before restart */ - sum=0; - ptr = &SysBase->SoftVer; - - i=((IPTR)&SysBase->IntVects[0] - (IPTR)&SysBase->SoftVer) / 2; - - /* Calculate sum for every static part from SoftVer to ChkSum */ - for (j = 0; j < i; j++) - sum+=*(ptr++); - - SysBase->ChkSum = ~sum; - - D(debugmem()); - - /* This will cause everything else to run. This call will not return. - This is because it eventually falls into strap, which will call - the bootcode, which itself is not supposed to return. It is up - to the DOS (whatever it is) to Permit(); RemTask(NULL); - */ - InitCode(RTF_COLDSTART, 0); - - /* There had better be some kind of task waiting to run. */ - return NULL; - - AROS_USERFUNC_EXIT -} - -#ifdef sysBase -#undef sysBase -#endif - -AROS_PLH1(struct ExecBase *, open, - AROS_LHA(ULONG, version, D0), - struct ExecBase *, SysBase, 1, Exec) -{ - AROS_LIBFUNC_INIT - - /* I have one more opener. */ - SysBase->LibNode.lib_OpenCnt++; - return SysBase; - AROS_LIBFUNC_EXIT -} - -AROS_PLH0(BPTR, close, - struct ExecBase *, SysBase, 2, Exec) -{ - AROS_LIBFUNC_INIT - - /* I have one fewer opener. */ - SysBase->LibNode.lib_OpenCnt--; - return 0; - AROS_LIBFUNC_EXIT -} diff --git a/arch/all-mingw32/exec/idletask.c b/arch/all-mingw32/exec/idletask.c deleted file mode 100644 index 86296ad514..0000000000 --- a/arch/all-mingw32/exec/idletask.c +++ /dev/null @@ -1,7 +0,0 @@ -/* - * idletask.c - * - * Created on: Jan 25, 2009 - * Author: misc - */ - diff --git a/arch/all-mingw32/exec/mmakefile.src b/arch/all-mingw32/exec/mmakefile.src index 405040ad60..72e0d2c0ea 100644 --- a/arch/all-mingw32/exec/mmakefile.src +++ b/arch/all-mingw32/exec/mmakefile.src @@ -1,8 +1,8 @@ # $Id$ include $(TOP)/config/make.cfg -CFILES := alert cachecleare coldreboot exec_init platform_init permit \ - shutdowna idletask +CFILES := alert cachecleare coldreboot platform_init \ + shutdowna USER_INCLUDES := -I$(SRCDIR)/$(CURDIR) -I$(SRCDIR)/rom/exec -I$(SRCDIR)/arch/all-mingw32/kernel diff --git a/arch/all-unix/kernel/kernel.c b/arch/all-unix/kernel/kernel.c index f7d7138353..1c50c8592f 100644 --- a/arch/all-unix/kernel/kernel.c +++ b/arch/all-unix/kernel/kernel.c @@ -47,6 +47,13 @@ sa.sa_handler = (SIGHANDLER_T)h ## _gate; #endif +/* + * This is the global SysBase. It needs to be somewhere so it's placed + * here. When UNIX-hosted AROS is made modular, this goes away and SysBase + * will be handled by bootstrap, like in Windows-hosted port + */ +struct ExecBase *SysBase; + static void core_Trap(int sig, regs_t *regs) { void (*trapHandler)(unsigned long, regs_t *) = NULL; diff --git a/rom/exec/exec_init.c b/rom/exec/exec_init.c index 6379b2dbf4..3cadbfc184 100644 --- a/rom/exec/exec_init.c +++ b/rom/exec/exec_init.c @@ -61,12 +61,6 @@ static const UBYTE name[] = MOD_NAME_STRING; static const UBYTE version[] = VERSION_STRING; extern void debugmem(void); -extern void idleTask(struct ExecBase *); - -/**************** GLOBAL SYSBASE ***************/ -#ifndef AROS_CREATE_ROM -struct ExecBase * SysBase = NULL; -#endif /* We temporarily redefine kprintf() so we use the real version in case @@ -168,24 +162,8 @@ AROS_UFH5S(void, VBlankServer, AROS_USERFUNC_EXIT } -AROS_UFH1(void, idleCount, - AROS_UFHA(struct ExecBase *, SysBase, A6)) -{ - AROS_USERFUNC_INIT - /* This keeps track of how many times the idle task becomes active. - Apart from also testing the tc_Launch vector, it also keeps a - count of how many times we've gone idle since startup. - */ - SysBase->IdleCount++; - AROS_USERFUNC_EXIT -} - extern ULONG SoftIntDispatch(); -#ifdef AROS_CREATE_ROM -# define sysBase SysBase -#endif - AROS_UFH3(LIBBASETYPEPTR, GM_UNIQUENAME(init), AROS_UFHA(ULONG, dummy, D0), AROS_UFHA(BPTR, segList, A0), @@ -196,14 +174,11 @@ AROS_UFH3(LIBBASETYPEPTR, GM_UNIQUENAME(init), struct Task *t; struct MemList *ml; - UBYTE *s; int i, j; UWORD sum; UWORD *ptr; -#ifndef AROS_CREATE_ROM SysBase = sysBase; -#endif KernelBase = OpenResource("kernel.resource"); if (!KernelBase) return NULL; @@ -348,10 +323,6 @@ AROS_UFH3(LIBBASETYPEPTR, GM_UNIQUENAME(init), AROS_USERFUNC_EXIT } -#ifdef sysBase -#undef sysBase -#endif - AROS_PLH1(struct ExecBase *, open, AROS_LHA(ULONG, version, D0), struct ExecBase *, SysBase, 1, Exec) -- 2.11.4.GIT