From 02a2dcac1a41872e1fec6d3b37ddd7ecae57eae4 Mon Sep 17 00:00:00 2001 From: "Christian A. Weber" Date: Thu, 16 Apr 1992 23:00:42 +0000 Subject: Initial revision --- SysStart.c | 220 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 220 insertions(+) create mode 100644 SysStart.c (limited to 'SysStart.c') diff --git a/SysStart.c b/SysStart.c new file mode 100644 index 0000000..808bc43 --- /dev/null +++ b/SysStart.c @@ -0,0 +1,220 @@ +/**************************************************************************** +** ** +** SysStart.c - Startet Exec MIT Betriebssystem ** +** ** +***************************************************************************** +** ** +** Modification History ** +** -------------------- ** +** ** +** 24-Feb-91 CHW Created this file from Start.S ** +** ** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +//#include +#include /* z.B. für __builtin_memcpy */ +#include + +#include + + +char ident[] = "$VER: SysStart 5.0 by Christian A. Weber (" __DATE__ ")"; +char CLI_Template[] = "CS=CHIPSIZE/N,FS=FASTSIZE/N,MOD/K,PRI/N"; +char CLI_Help[] = "Usage: SysStart [CHIPSIZE kbytes] [FASTSIZE kbytes] [MOD name] [PRI pri]"; + +extern __regargs void Exit(LONG); +extern void RawPrintfFunc(char *, ...); + +extern struct ExecBase *SysBase; +extern struct GfxBase *GfxBase; + +extern BPTR StdErr; /* Standard Error output stream */ +extern struct Custom far volatile custom; + +extern void __asm __far InitExec( + register __d0 LONG, register __d1 LONG, + register __d2 LONG, register __d3 LONG, register __d4 LONG, + register __a0 void *,register __a1 void *, + register __a2 void *,register __a3 void *); + + +struct +{ + LONG *ChipSizePtr; + LONG *FastSizePtr; + char *ModName; + LONG *PriPtr; +} argv; + + +UBYTE *chipbase; /* Startadresse des CHIP-RAMs für Exec */ +LONG chipsize; /* Grösse des CHIP-RAMs für Exec */ + +UBYTE *fastbase; /* Startadresse des FAST-RAMs für Exec */ +LONG fastsize; /* Grösse des FAST-RAMs für Exec */ + +UWORD dmaconsave, intenasave; +ULONG attnflags, vblankfreq, sysbplcon0; +BYTE oldtaskpri; + + +/***************************************************************************/ +/* Alles freigeben, back to DOS */ + +__saveds void ExitRoutine(void) +{ + int i; + custom.color[0] = 0x173; /* Grünlich */ + + RawPrintfFunc("SysStart: ExitRoutine()\r\n"); + printf("done.\n"); + + WaitBlit(); + DisownBlitter(); + + custom.cop1lc = (ULONG)GfxBase->copinit; /* Bild wieder einschalten */ + + custom.dmacon = 0x7FFF; + custom.dmacon = dmaconsave | DMAF_SETCLR; /* Original dmacon zurückholen */ + + custom.intena = 0x7FFF; + custom.intena = intenasave | INTF_SETCLR; /* Dito mit intena */ + + for(i=0; i<8; ++i) + custom.spr[i].dataa = custom.spr[i].datab = 0; + + RemakeDisplay(); + SetTaskPri(SysBase->ThisTask, oldtaskpri); + + if (fastbase) + { + FreeMem(fastbase, fastsize); + fastbase = NULL; + } + + if (chipbase) + { + FreeMem(chipbase, chipsize); + chipbase = NULL; + } + + CloseIntLib(); + CloseGfxLib(); + + Exit(RETURN_OK); +} + + +/***************************************************************************/ +/* Hauptprogramm */ + +LONG Main(LONG arglen, char *argline) +{ + char *module = "MainPrg"; + LONG taskpri=4; + + OpenGfxLib(); + OpenIntLib(); + + Puts(ident+6); + + AllocMem(0x40000000,0); /* Flushlibs */ + AllocMem(0x40000000,0); + + if (argv.ChipSizePtr) + { + chipsize = *argv.ChipSizePtr << 10; /* KBytes to Bytes */ + if(chipsize < 100000) + { + Puts("CHIP size must be > 100K, please try again!"); + return RETURN_ERROR; + } + } + else + { + chipsize = (AvailMem(MEMF_CHIP|MEMF_LARGEST) - 30000) & ~0xff; + if(chipsize > 1000000) + chipsize = (3*chipsize)/4; + } + + + if (argv.FastSizePtr) + { + fastsize = *argv.FastSizePtr << 10; + } + else + { + fastsize = (AvailMem(MEMF_FAST|MEMF_LARGEST) - 50000) & ~0xff; + if(fastsize > 1000000) + fastsize = (3*fastsize)/4; + } + + if (argv.ModName) + module = argv.ModName; + + if (argv.PriPtr) + taskpri = *argv.PriPtr; + + + if (chipbase = AllocMem(chipsize, MEMF_CHIP|MEMF_CLEAR)) + { + printf("Chip RAM: $%08lx (%ldK)\n", chipbase, chipsize >> 10); + + if (fastbase = AllocMem(fastsize, MEMF_FAST|MEMF_CLEAR)) + { + printf("Fast RAM: $%08lx (%ldK)\n", fastbase, fastsize >> 10); + } + else + { + fastsize = 0; + Puts("Not enough FAST RAM available"); + } + + OwnBlitter(); + WaitBlit(); + + oldtaskpri = SetTaskPri(SysBase->ThisTask,taskpri); + + /* System-Status für MyExec merken/retten etc. */ + + dmaconsave = custom.dmaconr; // &~DMAF_SPRITE; + intenasave = custom.intenar; // &~INTF_INTEN; + attnflags = SysBase->AttnFlags; + vblankfreq = SysBase->VBlankFrequency; + sysbplcon0 = GfxBase->system_bplcon0; + + custom.color[0] = 0xF00; /* Bildschirm rot */ + + printf("Running %s ... ", module); + RawPrintfFunc("%s: Running %s ...\r\n", ident+6, module); + + InitExec( attnflags, /* D0 */ + sysbplcon0, /* D1 */ + vblankfreq, /* D2 */ + 0, /* D3 : Product-Code */ + (LONG)module, /* D4 : MainPrg-Name */ + chipbase, /* A0 : CHIP-Startadresse */ + chipbase+chipsize, /* A1 : CHIP-Grösse */ + fastbase, /* A2 : FAST-Startadresse */ + fastbase+fastsize /* A3 : FAST-Endadresse */ + ); + + ExitRoutine(); + /* not reached */ + + } + else printf("Can't get %ldK CHIP RAM!\n",chipsize/1024); + + return RETURN_WARN; + +} -- cgit v1.2.3