void dopanic(const char *fmt, ...) { /* wrap the cursor */ cprintf("\033v\r\n"); /* TODO use sane screen settings (color, address) */ if (proc_lives != 0x12345678) { kcprintf("No saved info in dopanic; halted.\n"); halt(); } if (proc_enum == 0) { /* Call to panic(const char *fmt, ...) */ struct { LONG pc; } *s = (void *)proc_stk; va_list ap; va_start(ap, fmt); vkcprintf(fmt, ap); va_end(ap); kcprintf("pc = %08lx\n", s->pc); #ifdef __mcoldfire__ } else { /* On ColdFire, the exception frame is the same for all exceptions. */ struct { WORD format_word; WORD sr; LONG pc; } *s = (void *)proc_stk; if (proc_enum >= 2 && proc_enum < numberof(exc_messages)) { kcprintf("Panic: %s.\n", exc_messages[proc_enum]); } else { kcprintf("Panic: Exception number %d.\n", (int) proc_enum); } kcprintf("fw = %04x (format = %d, vector = %d, fault = %d), sr = %04x, pc = %08lx\n", s->format_word, (s->format_word & 0xf000) >> 12, (s->format_word & 0x03fc) >> 2, (s->format_word & 0x0c00) >> 8 | (s->format_word & 0x0002), s->sr, s->pc); } #else } else if (mcpu == 0 && (proc_enum == 2 || proc_enum == 3)) {
/* * xmgetblk - get a block of memory from the o/s pool. * * First try to get a block from the 'fast' list, anchored by root[4], * a list of blocks of size 64 bytes. This list is singly linked and * blocks are deleted/removed in LIFO order from the root. If there * are no free blocks on the list, we call getosm to get a block from * the os memory pool. * * If we cannot get memory for an MDBLOCK, we return NULL (the request * will fail). Otherwise we will attempt to free up DNDs to make space * and if that fails, the system will be halted. * * Arguments: * memtype: the type of request */ void *xmgetblk(WORD memtype) { WORD i, j, w, *m, *q, **r; if ((memtype < MEMTYPE_MDBLOCK) || (memtype > MEMTYPE_OFD)) { dbggtblk++; return NULL; } /* * allocate block */ i = 4; /* always from root[4] */ w = 32; /* number of words */ /* * we should execute the following loop a maximum of twice: the second * time only if we're allocating a DMD/DND/OFD & no memory is available */ for (j = 0; ; j++) { if ( *(r = &root[i]) ) /* there is an item on the free list */ { m = *r; /* get first item on list */ *r = *((WORD **) m); /* root points to next item */ break; } /* nothing on free list, try pool */ if ( (m = getosm(w+1)) ) /* include size of control word */ { *m++ = i; /* put size in control word */ break; } /* no memory available for an MDBLOCK, that's (sort of) OK */ if (memtype == MEMTYPE_MDBLOCK) break; /* * no memory for DMD/DND/OFD, try to get some * * note defensive programming: if free_available_dnds() said it * worked, but we're here again, then it lied and we should quit * to avoid an infinite loop */ if ((j >= 2) || (free_available_dnds() == 0)) { kcprintf(_("\033EOut of internal memory.\nUse FOLDR100.PRG to get more.\nSystem halted!\n")); halt(); /* halt system */ } } /* * zero out the block */ if ( (q = m) ) for (j = 0; j < w; j++) *q++ = 0; return m; }
void biosmain(void) { BOOL show_initinfo; /* TRUE if welcome screen must be displayed */ BYTE *p; bios_init(); /* Initialize the BIOS */ trap1( 0x30 ); /* initial test, if BDOS works: Sversion() */ if (!HAS_RTC) trap1( 0x2b, os_dosdate); /* set initial date in GEMDOS format: Tsetdate() */ /* Steem needs this to initialize its GEMDOS hard disk emulation. * This may change drvbits. See Steem sources: * File steem/code/emulator.cpp, function intercept_bios(). */ Drvmap(); /* * if it's not the first boot, we use the existing bootdev. * this allows a boot device that was selected via the welcome * screen to persist across warm boots. */ if (first_boot) bootdev = blkdev_avail(DEFAULT_BOOTDEV) ? DEFAULT_BOOTDEV : FLOPPY_BOOTDEV; #if INITINFO_DURATION == 0 show_initinfo = FALSE; #elif ALWAYS_SHOW_INITINFO show_initinfo = TRUE; #else show_initinfo = first_boot; #endif if (show_initinfo) bootdev = initinfo(); /* show the welcome screen */ KDEBUG(("bootdev = %d\n", bootdev)); /* boot eventually from a block device (floppy or harddisk) */ blkdev_boot(); defdrv = bootdev; trap1( 0x0e , defdrv ); /* Set boot drive: Dsetdrv(defdrv) */ #if ENABLE_RESET_RESIDENT run_reset_resident(); /* see comments above */ #endif /* * build default environment, just a PATH= string */ strcpy(default_env,PATH_ENV); p = default_env + sizeof(PATH_ENV); /* point to first byte of path string */ strcpy(p,DEF_PATH); *p = 'A' + defdrv; /* fix up drive letter */ p += sizeof(DEF_PATH); *p = '\0'; /* terminate with double nul */ #if WITH_CLI if (early_cli) { /* run an early console */ PD *pd = (PD *) trap1_pexec(PE_BASEPAGE, "", "", default_env); pd->p_tbase = (LONG) coma_start; pd->p_tlen = pd->p_dlen = pd->p_blen = 0; trap1_pexec(PE_GOTHENFREE, "", pd, ""); } #endif autoexec(); /* autoexec PRGs from AUTO folder */ /* clear commandline */ if(cmdload != 0) { /* Pexec a program called COMMAND.PRG */ trap1_pexec(PE_LOADGO, "COMMAND.PRG", "", default_env); } else if (exec_os) { /* start the default (ROM) shell */ PD *pd; pd = (PD *) trap1_pexec(PE_BASEPAGE, "", "", default_env); pd->p_tbase = (LONG) exec_os; pd->p_tlen = pd->p_dlen = pd->p_blen = 0; trap1_pexec(PE_GO, "", pd, ""); } #if CONF_WITH_SHUTDOWN /* try to shutdown the machine / close the emulator */ shutdown(); #endif /* hide cursor */ cprintf("\033f"); kcprintf(_("System halted!\n")); halt(); }