diff --git a/libemile/bootblock.h b/libemile/bootblock.h index 5b1f90b..cff53f2 100644 --- a/libemile/bootblock.h +++ b/libemile/bootblock.h @@ -12,7 +12,7 @@ #ifndef _BOOTBLOCK_H #define _BOOTBLOCK_H static __attribute__((used)) char* bootblock_header = "$CVSHeader$"; -#include "../second/glue.h" +#include /* first level structure */ diff --git a/second/arch.c b/second/arch.c index 84cbf37..87cb5e9 100644 --- a/second/arch.c +++ b/second/arch.c @@ -6,10 +6,12 @@ * */ +#include +#include +#include + #include "misc.h" -#include "glue.h" #include "arch.h" -#include "lowmem.h" #ifdef ARCH_PPC #include "bootx.h" #endif diff --git a/second/arch.h b/second/arch.h index d50da00..683272c 100644 --- a/second/arch.h +++ b/second/arch.h @@ -4,177 +4,6 @@ * */ -enum { - gestaltProcessorType = 'proc', - gestalt68000 = 1, - gestalt68010 = 2, - gestalt68020 = 3, - gestalt68030 = 4, - gestalt68040 = 5 -}; - -enum { - gestaltMMUType = 'mmu ', /* mmu type */ - gestaltNoMMU = 0, /* no MMU */ - gestaltAMU = 1, /* address management unit */ - gestalt68851 = 2, /* 68851 PMMU */ - gestalt68030MMU = 3, /* 68030 built-in MMU */ - gestalt68040MMU = 4, /* 68040 built-in MMU */ - gestaltEMMU1 = 5 /* Emulated MMU type 1 */ -}; - -enum { - gestaltFPUType = 'fpu ', /* fpu type */ - gestaltNoFPU = 0, /* no FPU */ - gestalt68881 = 1, /* 68881 FPU */ - gestalt68882 = 2, /* 68882 FPU */ - gestalt68040FPU = 3 /* 68040 built-in FPU */ -}; - -enum { - gestaltSysArchitecture = 'sysa', /* Native System Architecture */ - gestalt68k = 1, /* Motorola MC68k architecture */ - gestaltPowerPC = 2 /* IBM PowerPC architecture */ -}; - -enum { - gestaltMachineType = 'mach', /* machine type */ - gestaltClassic = 1, - gestaltMacXL = 2, - gestaltMac512KE = 3, - gestaltMacPlus = 4, - gestaltMacSE = 5, - gestaltMacII = 6, - gestaltMacIIx = 7, - gestaltMacIIcx = 8, - gestaltMacSE030 = 9, - gestaltPortable = 10, - gestaltMacIIci = 11, - gestaltPowerMac8100_120 = 12, - gestaltMacIIfx = 13, - gestaltMacClassic = 17, - gestaltMacIIsi = 18, - gestaltMacLC = 19, - gestaltMacQuadra900 = 20, - gestaltPowerBook170 = 21, - gestaltMacQuadra700 = 22, - gestaltClassicII = 23, - gestaltPowerBook100 = 24, - gestaltPowerBook140 = 25, - gestaltMacQuadra950 = 26, - gestaltMacLCIII = 27, - gestaltPerforma450 = gestaltMacLCIII, - gestaltPowerBookDuo210 = 29, - gestaltMacCentris650 = 30, - gestaltPowerBookDuo230 = 32, - gestaltPowerBook180 = 33, - gestaltPowerBook160 = 34, - gestaltMacQuadra800 = 35, - gestaltMacQuadra650 = 36, - gestaltMacLCII = 37, - gestaltPowerBookDuo250 = 38, - gestaltAWS9150_80 = 39, - gestaltPowerMac8100_110 = 40, - gestaltAWS8150_110 = gestaltPowerMac8100_110, - gestaltPowerMac5200 = 41, - gestaltPowerMac5260 = gestaltPowerMac5200, - gestaltPerforma5300 = gestaltPowerMac5200, - gestaltPowerMac6200 = 42, - gestaltPerforma6300 = gestaltPowerMac6200, - gestaltMacIIvi = 44, - gestaltMacIIvm = 45, - gestaltPerforma600 = gestaltMacIIvm, - gestaltPowerMac7100_80 = 47, - gestaltMacIIvx = 48, - gestaltMacColorClassic = 49, - gestaltPerforma250 = gestaltMacColorClassic, - gestaltPowerBook165c = 50, - gestaltMacCentris610 = 52, - gestaltMacQuadra610 = 53, - gestaltPowerBook145 = 54, - gestaltPowerMac8100_100 = 55, - gestaltMacLC520 = 56, - gestaltAWS9150_120 = 57, - gestaltPowerMac6400 = 58, - gestaltPerforma6400 = gestaltPowerMac6400, - gestaltPerforma6360 = gestaltPerforma6400, - gestaltMacCentris660AV = 60, - gestaltMacQuadra660AV = gestaltMacCentris660AV, - gestaltPerforma46x = 62, - gestaltPowerMac8100_80 = 65, - gestaltAWS8150_80 = gestaltPowerMac8100_80, - gestaltPowerMac9500 = 67, - gestaltPowerMac9600 = gestaltPowerMac9500, - gestaltPowerMac7500 = 68, - gestaltPowerMac7600 = gestaltPowerMac7500, - gestaltPowerMac8500 = 69, - gestaltPowerMac8600 = gestaltPowerMac8500, - gestaltAWS8550 = gestaltPowerMac7500, - gestaltPowerBook180c = 71, - gestaltPowerBook520 = 72, - gestaltPowerBook520c = gestaltPowerBook520, - gestaltPowerBook540 = gestaltPowerBook520, - gestaltPowerBook540c = gestaltPowerBook520, - gestaltPowerMac5400 = 74, - gestaltPowerMac6100_60 = 75, - gestaltAWS6150_60 = gestaltPowerMac6100_60, - gestaltPowerBookDuo270c = 77, - gestaltMacQuadra840AV = 78, - gestaltPerforma550 = 80, - gestaltPowerBook165 = 84, - gestaltPowerBook190 = 85, - gestaltMacTV = 88, - gestaltMacLC475 = 89, - gestaltPerforma47x = gestaltMacLC475, - gestaltMacLC575 = 92, - gestaltMacQuadra605 = 94, - gestaltMacQuadra630 = 98, - gestaltMacLC580 = 99, - gestaltPerforma580 = gestaltMacLC580, - gestaltPowerMac6100_66 = 100, - gestaltAWS6150_66 = gestaltPowerMac6100_66, - gestaltPowerMac6100_80 = 101, - gestaltPowerBookDuo280 = 102, - gestaltPowerBookDuo280c = 103, - gestaltPowerMacLC475 = 104, - gestaltPowerMacPerforma47x = gestaltPowerMacLC475, - gestaltPowerMacLC575 = 105, - gestaltPowerMacPerforma57x = gestaltPowerMacLC575, - gestaltPowerMacQuadra630 = 106, - gestaltPowerMacLC630 = gestaltPowerMacQuadra630, - gestaltPowerMacPerforma63x = gestaltPowerMacQuadra630, - gestaltPowerMac7200 = 108, - gestaltPowerMac7300 = 109, - gestaltPowerMac7100_66 = 112, - gestaltPowerMac7100_80_chipped= 113, - gestaltPowerBook150 = 115, - gestaltPowerMacQuadra700 = 116, - gestaltPowerMacQuadra900 = 117, - gestaltPowerMacQuadra950 = 118, - gestaltPowerMacCentris610 = 119, - gestaltPowerMacCentris650 = 120, - gestaltPowerMacQuadra610 = 121, - gestaltPowerMacQuadra650 = 122, - gestaltPowerMacQuadra800 = 123, - gestaltPowerBookDuo2300 = 124, - gestaltPowerBook500PPCUpgrade = 126, - gestaltPowerBook5300 = 128, - gestaltPowerBook1400 = 310, - gestaltPowerBook3400 = 306, - gestaltPowerBook2400 = 307, - gestaltPowerBookG3Series = 312, - gestaltPowerBookG3 = 313, - gestaltPowerBookG3Series2 = 314, - gestaltPowerMacNewWorld = 406, - gestaltPowerMacG3 = 510, - gestaltPowerMac5500 = 512, - gestalt20thAnniversary = gestaltPowerMac5500, - gestaltPowerMac6500 = 513, - gestaltPowerMac4400_160 = 514, - gestaltPowerMac4400 = 515, - gestaltMacOSCompatibility = 1206 -}; - extern unsigned long cpu_type; extern unsigned long mmu_type; extern unsigned long fpu_type; diff --git a/second/bank.c b/second/bank.c index 3679c48..adef622 100644 --- a/second/bank.c +++ b/second/bank.c @@ -9,9 +9,11 @@ #include #include +#include "macos/lowmem.h" +#include "macos/gestalt.h" + #include "misc.h" #include "arch.h" -#include "lowmem.h" #ifdef ARCH_M68K #include "MMU030.h" #include "MMU040.h" diff --git a/second/bootenv.c b/second/bootenv.c index 017296a..8b09c43 100644 --- a/second/bootenv.c +++ b/second/bootenv.c @@ -7,7 +7,9 @@ #include #include -#include "lowmem.h" +#include +#include + #include "arch.h" #include "vga.h" #include "bank.h" diff --git a/second/bootinfo.c b/second/bootinfo.c index 9305d11..f4cccd4 100644 --- a/second/bootinfo.c +++ b/second/bootinfo.c @@ -9,44 +9,18 @@ #include +#include +#include + #include "bank.h" #include "memory.h" #include "misc.h" -#include "glue.h" #include "vga.h" -#include "lowmem.h" #include "bootinfo.h" #include "arch.h" struct bootinfo boot_info; -enum { - gestaltHardwareAttr= 'hdwr', /* hardware attributes */ - gestaltHasVIA1 = 0, /* VIA1 exists */ - gestaltHasVIA2 = 1, /* VIA2 exists */ - gestaltHasRBV = 2, - gestaltHasASC = 3, /* Apple Sound Chip exists */ - gestaltHasSCC = 4, /* SCC exists */ - gestaltHasOSS = 5, - gestaltHasSCSIDMA = 6, - gestaltHasSCSI = 7, /* SCSI exists */ - gestaltHasSWIMIOP = 8, - gestaltHasSCCIOP = 9, - gestaltHasFitch = 10, - gestaltHasIWM = 11, - gestaltHasPWM = 12, - gestaltHasRAMSndBuff = 13, - gestaltHasVideoDAConv = 14, - gestaltHasPGC = 15, - gestaltHasSoftPowerOff = 19, /* Capable of software power off */ - gestaltHasSonic = 20, - gestaltHasSCSI961 = 21, /* 53C96 SCSI ctrl on internal bus */ - gestaltHasSCSI962 = 22, /* 53C96 SCSI ctrl on external bus */ - gestaltHasDAFBVideo = 23, - gestaltHasUniversalROM = 24, /* Do we have a Universal ROM? */ - gestaltHasEnhancedLtalk = 30 /* Do we have Enhanced LocalTalk? */ -}; - #if defined(EXTENDED_HW_MAP) static int diff --git a/second/console.c b/second/console.c index 52d2f9f..02b4929 100644 --- a/second/console.c +++ b/second/console.c @@ -6,11 +6,11 @@ #include -#include "console.h" +#include +#include "console.h" #include "vga.h" #include "serial.h" -#include "lowmem.h" #include "keyboard.h" static int vga_enabled = 0; @@ -27,7 +27,7 @@ console_init(emile_l2_header_t* info) serial_init(info); } -inline int console_putchar(int c) +int console_putchar(int c) { if (vga_enabled) vga_put(c); diff --git a/second/console.h b/second/console.h index 7cd1a4e..fed85e7 100644 --- a/second/console.h +++ b/second/console.h @@ -7,6 +7,8 @@ #ifndef __CONSOLE_H__ #define __CONSOLE_H__ +#include + #include "misc.h" #include "head.h" diff --git a/second/driver.c b/second/driver.c index eb09893..f7c0013 100644 --- a/second/driver.c +++ b/second/driver.c @@ -8,150 +8,11 @@ #include #include +#include +#include +#include + #include "misc.h" -#include "glue.h" -#include "lowmem.h" - -/* - * OpenDriver: - * - * http://developer.apple.com/documentation/mac/Devices/Devices-23.html - * - */ - -OSErr OpenDriver(ConstStr255Param name, short *drvrRefNum) -{ - OSErr err; - ParamBlockRec param; - - memset(¶m, 0, sizeof(ParamBlockRec)); - - param.ioNamePtr = (unsigned char*)name; - param.ioPermssn = fsCurPerm; - - err = PBOpenSync(¶m); - if (err != noErr) - return err; - - *drvrRefNum = param.ioRefNum; - - return param.ioResult; -} - -OSErr CloseDriver(short refNum) -{ - OSErr err; - ParamBlockRec param; - - memset(¶m, 0, sizeof(ParamBlockRec)); - - param.ioRefNum = refNum; - - err = PBCloseSync(¶m); - if (err != noErr) - return err; - - return param.ioResult; -} - -ssize_t write(int fd, const void *buf, size_t count) -{ - int res; - ParamBlockRec param; - - param.ioCompletion = 0; - param.ioVRefNum = 0; - param.ioRefNum = fd; - param.ioBuffer = (u_int32_t)buf; - param.ioReqCount= count; - param.ioPosMode = fsAtMark; - param.ioPosOffset = 0; - res = PBWriteSync(¶m); - if (res != noErr) - return 0; - - return param.ioActCount; -} - -#ifdef USE_CLI - -static OSErr SerGetBuf(short refNum, long *count) -{ - int res; - CntrlParam param; - - param.ioCompletion = 0; - param.ioVRefNum = 0; - param.ioCRefNum = refNum; - param.csCode = kSERDInputCount; - - res = PBStatusSync((ParmBlkPtr)¶m); - - *count = *(long*)¶m.csParam; - - return res; -} - -ssize_t read(int fd, void *buf, size_t count) -{ - int res; - ParamBlockRec param; - long available; - - res = SerGetBuf(fd, &available); - if ( (res != noErr) || (available == 0) ) - return 0; - - param.ioCompletion = 0; - param.ioVRefNum = 0; - param.ioRefNum = fd; - param.ioBuffer = (u_int32_t)buf; - param.ioReqCount= count > available ? available : count; - param.ioPosMode = fsAtMark; - param.ioPosOffset = 0; - res = PBReadSync(¶m); - if (res != noErr) - return 0; - return param.ioActCount; -} -#endif - -typedef struct -{ - short drvrFlags; - short drvrDelay; - short drvrEMask; - short drvrMenu; - short drvrOpen; - short drvrPrime; - short drvrCtl; - short drvrStatus; - short drvrClose; - unsigned char drvrName[]; -} DriverHeader; -enum { -dVMImmuneMask = 0x0001, /* driver does not need VM protection */ -dOpenedMask = 0x0020, /* driver is open */ -dRAMBasedMask = 0x0040, /* dCtlDriver is a handle (1) or pointer (0) */ -drvrActiveMask = 0x0080 /* driver is currently processing a request */ -}; - -struct DCtlEntry { -void* dCtlDriver; -volatile short dCtlFlags; -void* dCtlQHdr; -volatile long dCtlPosition; -void** dCtlStorage; -short dCtlRefNum; -long dCtlCurTicks; -void* dCtlWindow; -short dCtlDelay; -short dCtlEMask; -short dCtlMenu; -}; -typedef struct DCtlEntry DCtlEntry; -typedef DCtlEntry * DCtlPtr; -typedef DCtlPtr * DCtlHandle; void turn_off_interrupts() { @@ -161,7 +22,7 @@ void turn_off_interrupts() DCtlPtr currentPtr; DriverHeader *driverPtr, **driverHandle; short refnum; - OSErr err; + volatile OSErr err; /* because -O2 remove call to PBControlSync() otherwise... */ VDParamBlock pb; VDFlagRec flag; diff --git a/second/driver.h b/second/driver.h index 2f122a3..c1635c8 100644 --- a/second/driver.h +++ b/second/driver.h @@ -4,11 +4,4 @@ * */ -extern OSErr OpenDriver(ConstStr255Param name, short *drvrRefNum); -OSErr CloseDriver(short refNum); -extern ssize_t write(int fd, const void *buf, size_t count); -#ifdef USE_CLI -extern ssize_t read(int fd, void *buf, size_t count); -extern OSErr SerGetBuf(short refNum, long *count); -#endif extern void turn_off_interrupts(); diff --git a/second/enter_kernel.c b/second/enter_kernel.c index 3bf3c64..415104a 100644 --- a/second/enter_kernel.c +++ b/second/enter_kernel.c @@ -6,6 +6,9 @@ #include +#include +#include + #include "misc.h" #include "arch.h" #include "enter_kernel.h" diff --git a/second/glue.S b/second/glue.S deleted file mode 100644 index 21e0694..0000000 --- a/second/glue.S +++ /dev/null @@ -1,607 +0,0 @@ -/* - * - * (c) 2004,2005 Laurent Vivier - * - * Some parts from libgcc routines for 68000 w/o floating-point hardware. - * Copyright (C) 1994, 1996, 1997, 1998 Free Software Foundation, Inc. - * - */ - - .chip 68000 - - .align 2 - - .globl __mulsi3 -__mulsi3: - movew %sp@(4), %d0 /* x0 -> %d0 */ - muluw %sp@(10), %d0 /* x0*y1 */ - movew %sp@(6), %d1 /* x1 -> %d1 */ - muluw %sp@(8), %d1 /* x1*y0 */ - addl %d1, %d0 - swap %d0 - clrw %d0 - movew %sp@(6), %d1 /* x1 -> %d1 */ - muluw %sp@(10), %d1 /* x1*y1 */ - addl %d1, %d0 - rts - - .globl __udivsi3 -__udivsi3: - movel %d2, %sp@- - movel %sp@(12), %d1 /* %d1 = divisor */ - movel %sp@(8), %d0 /* %d0 = dividend */ - - cmpl #0x10000, %d1 /* divisor >= 2 ^ 16 ? */ - jcc __udivsi3L3 /* then try next algorithm */ - movel %d0, %d2 - clrw %d2 - swap %d2 - divu %d1, %d2 /* high quotient in lower word */ - movew %d2, %d0 /* save high quotient */ - swap %d0 - movew %sp@(10), %d2 /* get low dividend + high rest */ - divu %d1, %d2 /* low quotient */ - movew %d2, %d0 - jra __udivsi3L6 - -__udivsi3L3: movel %d1, %d2 /* use %d2 as divisor backup */ -__udivsi3L4: lsrl #1, %d1 /* shift divisor */ - lsrl #1, %d0 /* shift dividend */ - cmpl #0x10000, %d1 /* still divisor >= 2 ^ 16 ? */ - jcc __udivsi3L4 - divu %d1, %d0 /* now we have 16-bit divisor */ - andl #0xffff, %d0 /* mask out divisor, ignore remainder */ - -/* Multiply the 16-bit tentative quotient with the 32-bit divisor. Because of - the operand ranges, this might give a 33-bit product. If this product is - greater than the dividend, the tentative quotient was too large. */ - movel %d2, %d1 - mulu %d0, %d1 /* low part, 32 bits */ - swap %d2 - mulu %d0, %d2 /* high part, at most 17 bits */ - swap %d2 /* align high part with low part */ - tstw %d2 /* high part 17 bits? */ - jne __udivsi3L5 /* if 17 bits, quotient was too large */ - addl %d2, %d1 /* add parts */ - jcs __udivsi3L5 /* if sum is 33 bits, quotient was too large */ - cmpl %sp@(8), %d1 /* compare the sum with the dividend */ - jls __udivsi3L6 /* if sum > dividend, quotient was too large */ -__udivsi3L5: subql #1, %d0 /* adjust quotient */ - -__udivsi3L6: movel %sp@+, %d2 - rts - - .globl __divsi3 -__divsi3: - movel %d2, %sp@- - - moveq #1, %d2 /* sign of result stored in %d2 (=1 or =-1) */ - movel %sp@(12), %d1 /* %d1 = divisor */ - jpl __divsi3L1 - negl %d1 - negb %d2 /* change sign because divisor <0 */ -__divsi3L1: movel %sp@(8), %d0 /* %d0 = dividend */ - jpl __divsi3L2 - negl %d0 - negb %d2 - -__divsi3L2: movel %d1, %sp@- - movel %d0, %sp@- - bsr __udivsi3 /* divide abs(dividend) by abs(divisor) */ - addql #8, %sp - - tstb %d2 - jpl __divsi3L3 - negl %d0 - -__divsi3L3: movel %sp@+, %d2 - rts - - .globl __umodsi3 -__umodsi3: - movel %sp@(8), %d1 /* %d1 = divisor */ - movel %sp@(4), %d0 /* %d0 = dividend */ - movel %d1, %sp@- - movel %d0, %sp@- - bsr __udivsi3 - addql #8, %sp - movel %sp@(8), %d1 /* %d1 = divisor */ - movel %d1, %sp@- - movel %d0, %sp@- - bsr __mulsi3 /* %d0 = (a/b)*b */ - addql #8, %sp - movel %sp@(4), %d1 /* %d1 = dividend */ - subl %d0, %d1 /* %d1 = a - (a/b)*b */ - movel %d1, %d0 - rts - - .globl __modsi3 -__modsi3: - movel %sp@(8), %d1 /* %d1 = divisor */ - movel %sp@(4), %d0 /* %d0 = dividend */ - movel %d1, %sp@- - movel %d0, %sp@- - bsr __divsi3 - addql #8, %sp - movel %sp@(8), %d1 /* %d1 = divisor */ - movel %d1, %sp@- - movel %d0, %sp@- - bsr __mulsi3 /* %d0 = (a/b)*b */ - addql #8, %sp - movel %sp@(4), %d1 /* %d1 = dividend */ - subl %d0, %d1 /* %d1 = a - (a/b)*b */ - movel %d1, %d0 - rts - - /* void InitGraf(void * port); */ - - .global InitGraf -InitGraf: - link %fp, #0 - move.l 8(%fp), -(%sp) /* port */ - dc.w 0xA86E - unlk %fp - rts - -/* #include - * #include - */ - - .globl glue_display_properties - .type glue_display_properties,@function - -/* - * int - * glue_display_properties(unsigned long *base, unsigned long *row_bytes, - * unsigned long *width, unsigned long *height, - * unsigned long *depth, unsigned long* video) - */ - -glue_display_properties: - /* - * GDHandle hdl; - * volatile PixMapPtr pm; - */ - - link.w %a6,#-4 - movem.l %a2-%a4, %sp@- - - movm.l #0x3c,-(%sp) - move.l 28(%a6),%a3 /* unsigned long *video */ - move.l 12(%a6),%a5 /* unsigned long *row_bytes */ - move.l 24(%a6),%a4 /* unsigned long *depth */ - - /* hdl = LMGetMainDevice(); */ - - move.l 0x08A4,%a0 - - - /* if (hdl == 0xAAAAAAAA || hdl == NULL || (**hdl).gdPMap == NULL) - * return; - */ - - cmpa.l #0xAAAAAAAA, %a0 - jbeq .exit_error -cmpa.l #0, %a0 - jbeq .exit_error - move.l (%a0),%a0 - tst.l 22(%a0) - jbeq .exit_error - - /* pm = *(**hdl).gdPMap; */ - - move.l 22(%a0),%a0 - - /* if (pm->baseAddr == NULL) - * return; - */ - - move.l (%a0),-4(%a6) - move.l -4(%a6),%a0 - tst.l (%a0) - jbeq .exit_error - - /* *video = (unsigned char *)pm->baseAddr; */ - - move.l -4(%a6),%a0 - move.l (%a0),(%a3) - - - /* *row_bytes = pm->rowBytes & 0x3fff; */ - - move.l -4(%a6),%a0 - move.w 4(%a0),%d0 - and.l #16383,%d0 - move.l %d0,(%a5) - - /* *width = pm->bounds.right - pm->bounds.left; */ - - move.l -4(%a6),%a0 - move.w 12(%a0),%a2 - move.l -4(%a6),%a1 - move.l 16(%a6),%a0 - sub.w 8(%a1),%a2 - move.l %a2,(%a0) - - /* *height = pm->bounds.bottom - pm->bounds.top; */ - - move.l -4(%a6),%a0 - move.w 10(%a0),%a2 - move.l -4(%a6),%a1 - move.l 20(%a6),%a0 - sub.w 6(%a1),%a2 - move.l %a2,(%a0) - - /* *depth = pm->pixelSize; */ - - move.l -4(%a6),%a0 - move.w 32(%a0),%a0 - move.l %a0,(%a4) - - /* if (*depth == 15) *depth = 16; */ - - moveq.l #15,%d0 - cmp.l %a0,%d0 - jbne .not_15 - moveq.l #16,%d0 - move.l %d0,(%a4) -.not_15: - - /* (*base) = (*video) */ - - move.l (%a3),%d0 - move.l 8(%a6),%a3 /* unsigned long *base */ - move.l %d0,(%a3) - - /* (*base) = (*video) + pm->bounds.top * *row_bytes; */ - - move.l -4(%a6),%a0 - move.w 6(%a0),%d0 - - /* add 68000 support, - * - * row_bytes can be stored on a short - * - */ - - move.l (%a5), %d1 - muls.w %d1, %d0 - - add.l %d0,(%a3) - - /* (*base) += pm->bounds.left * ((*depth) >> 3); */ - - move.l -4(%a6),%a0 - move.w 8(%a0),%d1 - move.l (%a4),%d0 - lsr.l #3,%d0 - - /* add 68000 support, - * - * NOTE: depth can be stored on a short - * - */ - - muls.w %d0, %d1 - - add.l %d1,(%a3) - -.exit: - movm.l (%sp)+,#0x3c00 - movem.l %sp@+, %a2-%a4 - unlk %a6 - moveq.l #0, %d0 - rts -.exit_error: - movm.l (%sp)+,#0x3c00 - movem.l %sp@+, %a2-%a4 - unlk %a6 - moveq.l #-1, %d0 - rts - - /* OSErr Gestalt(OSType selector, long * response) */ - - .global Gestalt -Gestalt: - link %fp, #0 - move.l 8(%fp), %d0 - dc.w 0xA1AD /* Gestalt */ - move.l 12(%fp), %a1 - move.l %a0, %a1@ - unlk %fp - rts - - /* void ReadLocation(MachineLocation * loc) */ - - .global ReadLocation -ReadLocation: - link %fp, #0 - move.l 8(%fp), %a0 - move.l #0x000C00E4, %d0 /* ReadLocation */ - dc.w 0xA051 /* ReadXPRam */ - unlk %fp - rts - - /* void* NewPtr(unsigned long byteCount) */ - - .global NewPtr -NewPtr: - link %fp, #0 - move.l 8(%fp), %d0 - dc.w 0xA11E /* NewPtr */ - move.l %a0, %d0 - unlk %fp - rts - - /* void DisposePtr(void* ptr) */ - - .global DisposePtr -DisposePtr: - link %fp, #0 - move.l 8(%fp), %a0 - dc.w 0xA01F /* DisposePtr */ - unlk %fp - rts - - /* OSErr PBReadSync(ParamBlockRec_t* paramBlock) */ - - .global PBReadSync -PBReadSync: - link %fp, #0 - move.l 8(%fp), %a0 - dc.w 0xA002 /* PBReadSync */ - unlk %fp - rts - - /* OSErr PBWriteSync(ParamBlockRec_t* paramBlock) */ - - .global PBWriteSync -PBWriteSync: - link %fp, #0 - move.l 8(%fp), %a0 - dc.w 0xA003 /* PBWriteSync */ - unlk %fp - rts - - /* OSErr PBOpenSync(ParmBlkPtr paramBlock) */ - - .global PBOpenSync -PBOpenSync: - link %fp, #0 - move.l 8(%fp), %a0 - dc.w 0xA000 /* PBOpenSync */ - unlk %fp - rts - - /* OSErr PBCloseSync(ParmBlkPtr paramBlock) */ - - .global PBCloseSync -PBCloseSync: - link %fp, #0 - move.l 8(%fp), %a0 - dc.w 0xA001 /* PBCloseSync */ - unlk %fp - rts - - /* OSErr PBControlSync(ParmBlkPtr paramBlock) */ - - .global PBControlSync -PBControlSync: - link %fp, #0 - move.l 8(%fp), %a0 - dc.w 0xA004 /* PBControlSync */ - unlk %fp - rts - - /* OSErr PBStatusSync(ParmBlkPtr paramBlock) */ - - .global PBStatusSync -PBStatusSync: - link %fp, #0 - move.l 8(%fp), %a0 - dc.w 0xA005 /* PBStatusSync */ - unlk %fp - rts - - /* void SysError(short errorCode) */ - - .global SysError -SysError: - link %fp, #0 - move.l 8(%fp), %d0 - dc.w 0xA9C9 /* SysError */ - unlk %fp - rts - - /* void GetKeys(KeyMap); */ - - .global GetKeys -GetKeys: - link %fp, #0 - move.l 8(%fp), %d0 - move.l %d0, -(%sp) - dc.w 0xA976 /* GetKeys */ - unlk %fp - rts - - /* void InitFS(short CntFCBs) */ - - .global InitFS -InitFS: - link %fp, #0 - move.l 8(%fp), %d0 - dc.w 0xA06C /* InitFS */ - unlk %fp - rts - - /* void InitEvents(short CntEvts) */ - - .global InitEvents -InitEvents: - link %fp, #0 - move.l 8(%fp), %d0 - dc.w 0xA06D /* InitEvents */ - unlk %fp - rts - - /* void FInitQueue(void) */ - - .global FInitQueue -FInitQueue: - link %fp, #0 - dc.w 0xA016 /* FInitQueue */ - unlk %fp - rts - - /* OSErr PBGetVInfoSync(ParmBlkPtr paramBlock) */ - - .global PBGetVInfoSync -PBGetVInfoSync: - link %fp, #0 - move.l 8(%fp), %a0 - dc.w 0xA007 /* GetVolInfo */ - unlk %fp - rts - - /* OSErr PBMountVol(ParmBlkPtr paramBlock) */ - - .global PBMountVol -PBMountVol: - link %fp, #0 - move.l 8(%fp), %a0 - dc.w 0xA00F /* MountVol */ - unlk %fp - rts - -#if defined(NEED_SLOT_RESOURCES) - /* OSErr SGetCString(SpBlockPtr spBlkPtr) */ - - .global SGetCString -SGetCString: - link %fp, #0 - move.l 8(%fp), %a0 - move.l #0x03, %d0 /* SGetCString */ - dc.w 0xA06E /* _SlotManager */ - unlk %fp - rts - - /* OSErr SRsrcInfo(SpBlockPtr spBlkPtr) */ - - .global SRsrcInfo -SRsrcInfo: - link %fp, #0 - move.l 8(%fp), %a0 - move.l #0x16, %d0 /* SRsrcInfo */ - dc.w 0xA06E /* _SlotManager */ - unlk %fp - rts - - /* OSErr SGetTypeSRsrc(SpBlockPtr spBlkPtr) */ - - .global SGetTypeSRsrc -SGetTypeSRsrc: - link %fp, #0 - move.l 8(%fp), %a0 - move.l #0x0C, %d0 /* SGetTypeSRsrc */ - dc.w 0xA06E /* _SlotManager */ - unlk %fp - rts -#endif /* NEED_SLOT_RESOURCES */ - -#if defined(SCSI_SUPPORT) - - /* SCSI support */ - -.equ _SCSIReset, 0x0000 -.equ _SCSIGet, 0x0001 -.equ _SCSISelect, 0x0002 -.equ _SCSICmd, 0x0003 -.equ _SCSIComplete, 0x0004 -.equ _SCSIRead, 0x0005 -.equ _SCSIWrite, 0x0006 - -.macro SCSIDispatch selector - move.w #\selector, -(%sp) - dc.w 0xA815 /* _SCSIDispatch */ - move.w (%sp)+, %d0 - ext.l %d0 -.endm - - /* OSErr SCSIReset(void) */ - - .global SCSIReset -SCSIReset: - link %fp, #0 - clr.w -(%sp) - SCSIDispatch(_SCSIReset) - unlk %fp - rts - - /* OSErr SCSIGet(void) */ - - .global SCSIGet -SCSIGet: - link %fp, #0 - clr.w -(%sp) - SCSIDispatch(_SCSIGet) - unlk %fp - rts - - /* OSErr SCSISelect(short targetID) */ - - .global SCSISelect -SCSISelect: - link %fp, #0 - move.l 8(%fp), %d0 /* targetID */ - clr.w -(%sp) - move.w %d0, -(%sp) - SCSIDispatch(_SCSISelect) - unlk %fp - rts - - /* OSErr SCSICmd(void* buffer, short count) */ - - .global SCSICmd -SCSICmd: - link %fp, #0 - move.l 8(%fp), %d0 /* buffer */ - move.l 12(%fp), %d1 /* count */ - clr.w -(%sp) - move.l %d0, -(%sp) /* buffer */ - move.w %d1, -(%sp) /* count */ - SCSIDispatch(_SCSICmd) - unlk %fp - rts - - /* OSErr SCSIRead(void *tibPtr) */ - - .global SCSIRead -SCSIRead: - link %fp, #0 - move.l 8(%fp), %d0 /* tibPtr */ - clr.w -(%sp) - move.l %d0, -(%sp) - SCSIDispatch(_SCSIRead) - unlk %fp - rts - - /* OSErr SCSIComplete(short *stat, short *message, unsigned long wait)*/ - - .global SCSIComplete -SCSIComplete: - link %fp, #0 - move.l %d2, %sp@- - move.l %d0, -(%sp) - move.l 8(%fp), %d0 /* stat */ - move.l 12(%fp), %d1 /* message */ - move.l 16(%fp), %d2 /* wait */ - clr.w -(%sp) - move.l %d0, -(%sp) - move.l %d1, -(%sp) - move.l %d2, -(%sp) - SCSIDispatch(_SCSIComplete) - move.l %sp@+, %d2 - unlk %fp - rts - -#endif /* SCSI_SUPPORT */ diff --git a/second/glue.h b/second/glue.h deleted file mode 100644 index e9d4f88..0000000 --- a/second/glue.h +++ /dev/null @@ -1,401 +0,0 @@ -/* - * - * (c) 2004 Laurent Vivier - * - */ - -typedef int16_t OSErr; -typedef unsigned char Str255[256]; -typedef const unsigned char * ConstStr255Param; -typedef unsigned char Str27[28]; - -enum { - noErr = 0, - qErr = -1, - vTypErr = -2, - corErr = -3, - unimpErr = -4, - SlpTypeErr = -5, - seNoDB = -8, - controlErr = -17, - statusErr = -18, - readErr = -19, - writErr = -20, - badUnitErr = -21, - unitEmptyErr = -22, - openErr = -23, - closErr = -24, - dRemovErr = -25, - dInstErr = -26, - paramErr = -50, - userCanceledErr = -128, - noHardwareErr = -200, - notEnoughHardwareErr = -201, - smNoMoresRsrcs = -344, -}; - -enum { - false = 0, - true = 1 -}; - -struct MachineLocation -{ - int32_t latitude; - int32_t longitude; - union - { - int8_t dlsDelta; - int32_t gmtDelta; - } u; -}; -typedef struct MachineLocation MachineLocation; - -/* ParamBlockRec Structure: "Inside Macintosh: Files", p. 2-87 */ - -enum { - fsAtMark = 0, - fsFromStart = 1, - fsFromLEOF = 2, - fsFromMark = 3 -}; - -/* access permissions : Inside Macintosh: Devices - * http://developer.apple.com/documentation/mac/Devices/ - */ - -enum { - fsCurPerm = 0, /* retain current permission */ - fsRdPerm = 1, /* allow reads only */ - fsWrPerm = 2, /* allow writes only */ - fsRdWrPerm = 3 /* allow reads and writes */ -}; - -enum { - baud150 = 763, - baud300 = 380, - baud600 = 189, - baud1200 = 94, - baud1800 = 62, - baud2400 = 46, - baud3600 = 30, - baud4800 = 22, - baud7200 = 14, - baud9600 = 10, - baud14400 = 6, - baud19200 = 4, - baud28800 = 2, - baud38400 = 1, - baud57600 = 0 -}; - -enum { - data5 = 0, - data6 = 2048, - data7 = 1024, - data8 = 3072 -}; - -enum { - noParity = 0, - oddParity = 4096, - evenParity = 12288 -}; - -enum { - stop10 = 16384, - stop15 = -32768L, - stop20 = -16384 -}; - -enum { - kSERDConfiguration = 8, - kSERDInputBuffer = 9, - kSERDSerHShake = 10, - kSERDClearBreak = 11, - kSERDSetBreak = 12, - kSERDBaudRate = 13, - kSERDHandshake = 14, - kSERDClockMIDI = 15, - kSERDMiscOptions = 16, - kSERDAssertDTR = 17, - kSERDNegateDTR = 18, - kSERDSetPEChar = 19, - kSERDSetPEAltChar = 20, - kSERDSetXOffFlag = 21, - kSERDClearXOffFlag = 22, - kSERDSendXOn = 23, - kSERDSendXOnOut = 24, - kSERDSendXOff = 25, - kSERDSendXOffOut = 26, - kSERDResetChannel = 27, - kSERDHandshakeRS232 = 28, - kSERDStickParity = 29, - kSERDAssertRTS = 30, - kSERDNegateRTS = 31, - kSERD115KBaud = 115, - kSERD230KBaud = 230 -}; - -#define COMMON_PARAMS \ - void* qLink; /* next queue entry */ \ - u_int16_t qType; /* queue type */ \ - u_int16_t ioTrap; /* routine trap */ \ - void* ioCmdAddr; /* routine address */ \ - void* ioCompletion; /* ptr to completion routine */ \ - u_int16_t ioResult; /* result code */ \ - unsigned char* ioNamePtr; /* pointer to pathname */ \ - int16_t ioVRefNum; /* volume specification */ - -typedef struct ParamBlockRec ParamBlockRec_t; -struct ParamBlockRec { - COMMON_PARAMS - int16_t ioRefNum; /* file reference number */ - int8_t ioVersNum; /* version number */ - int8_t ioPermssn; /* read/write permission */ - u_int32_t ioMisc; /* miscellaneaous */ - u_int32_t ioBuffer; /* data buffer */ - u_int32_t ioReqCount; /* requested number of bytes */ - u_int32_t ioActCount; /* actual number of bytes */ - u_int16_t ioPosMode; /* positioning mode and newline char */ - int32_t ioPosOffset; /* positionning offset */ -} __attribute__((packed)); -typedef struct ParamBlockRec ParamBlockRec; -typedef struct ParamBlockRec* ParmBlkPtr; - -struct CntrlParam { - COMMON_PARAMS - int16_t ioCRefNum; - int16_t csCode; - int16_t csParam[11]; -}; -typedef struct CntrlParam CntrlParam; -typedef CntrlParam* CntrlParamPtr; - -struct VolumeParam { - COMMON_PARAMS - int32_t filler2; - int16_t ioVolIndex; /* Volume index number */ - u_int32_t ioVCrDate; /* Creation date/time */ - u_int32_t ioVLsBkUp; /* Last backup date/time */ - u_int16_t ioVAtrb; /* Volume attr */ - u_int16_t ioVNmFls; /* Number of files in directory */ - u_int16_t ioVDirSt; /* Start block of file directory */ - int16_t ioVBlLn; /* GetVolInfo: - * length of dir in blocks - */ - u_int16_t ioVNmAlBlks; /* For compatibilty: - * ioVNmAlBlks * ioVAlBlkSiz <= 2 GB - */ - u_int32_t ioVAlBlkSiz; /* For compatibilty: - * ioVAlBlkSiz is <= $0000FE00 (65,024) - */ - u_int32_t ioVClpSiz; /*GetVolInfo: bytes to allocate at a time*/ - u_int16_t ioAlBlSt; /* Starting disk(512-byte) block in block map */ - u_int32_t ioVNxtFNum; /* GetVolInfo: - * next free file number - */ - u_int16_t ioVFrBlk; /* GetVolInfo: - * # free alloc blks for this volume - */ -}; -typedef struct VolumeParam VolumeParam; -typedef VolumeParam* VolumeParamPtr; -#define ASSERT_PBR(a) if ( sizeof(ParamBlockRec_t) != 50 ) { a } - -struct Rect { - int16_t top; - int16_t left; - int16_t bottom; - int16_t right; -}; -typedef struct Rect Rect; -typedef Rect* RectPtr; - -struct Point { - int16_t v; - int16_t h; -}; -typedef struct Point Point; -typedef Point* PointPtr; - -struct BitMap { - void* baseAddr; - int16_t rowBytes; - Rect bounds; -}; -typedef struct BitMap BitMap; -typedef BitMap* BitMapPtr; -typedef BitMapPtr* BitMapHandle; - -struct Bits16 { - u_int16_t elements[16]; -}; -typedef struct Bits16 Bits16; - -struct Cursor { - Bits16 data; - Bits16 mask; - Point hotSpot; -}; -typedef struct Cursor Cursor; -typedef Cursor* CursorPtr; -typedef CursorPtr* CursorHandle; - -struct Pattern { - u_int8_t pat[8]; -}; -typedef struct Pattern Pattern; - -typedef void* GrafPtr; -struct QDGlobals { - int8_t privates[76]; - int32_t randSeed; - BitMap screenBits; - Cursor arrow; - Pattern dkGray; - Pattern ltGray; - Pattern gray; - Pattern black; - Pattern white; - GrafPtr thePort; -}; -typedef struct QDGlobals QDGlobals; -typedef struct QDGlobals* QDGlobalsPtr; -typedef struct QDGlobalsPtr* QDGlobalsHandle; - -extern void InitGraf(void * port); -extern int glue_display_properties(unsigned long *base, - unsigned long *row_bytes, - unsigned long *width, unsigned long *height, - unsigned long *depth, unsigned long *video); -extern OSErr Gestalt(unsigned long selector, long * response); -extern void ReadLocation(MachineLocation * loc); -extern void* NewPtr(unsigned long byteCount); -extern void DisposePtr(void* ptr); - -enum { - kSERDInputCount = 2, /* get available characters count (SerGetBuf) */ - kSERDStatus = 8, /* get status information (SerStatus) */ - kSERDVersion = 9, /* get driver version */ -}; - -extern OSErr PBReadSync(ParamBlockRec_t* paramBlock); -extern OSErr PBWriteSync(ParamBlockRec_t* paramBlock); -extern OSErr PBOpenSync(ParmBlkPtr paramBlock); -extern OSErr PBCloseSync(ParmBlkPtr paramBlock); -extern OSErr PBControlSync(ParmBlkPtr paramBlock); -extern OSErr PBStatusSync(ParmBlkPtr paramBlock); -extern void SysError(short errorCode); - -typedef u_int32_t KeyMap[4]; - -extern void GetKeys(KeyMap); - -#ifdef NEED_SLOT_RESOURCES -enum { - sRsrcType = 1, /* Type of sResource */ - sRsrcName = 2, /* Name of sResource */ - sRsrcIcon = 3, /* Icon */ - sRsrcDrvrDir = 4, /* Driver Directory */ - sRsrcLoadDir = 5, /* Load directory */ - sRsrcBootRec = 6, /* sBoot record */ - sRsrcFlags = 7, /* sResourceFlags */ - sRsrcHWDevId = 8, /* Hardware Device ID */ -}; - -struct SpBlock { - long spResult; - char* spsPointer; - long spSize; - long spOffsetData; - char* spIOFileName; - char* spsExecPBlk; - long spParamData; - long spMisc; - long spReserved; - short spIOReserved; - short spRefNum; - short spCategory; - short spCType; - short spDrvrSW; - short spDrvrHW; - int8_t spTBMask; - int8_t spSlot; - int8_t spID; - int8_t spExtDev; - int8_t spHwDev; - int8_t spByteLanes; - int8_t spFlags; - int8_t spKey; -} __attribute__((packed)) ; -typedef struct SpBlock SpBlock; -typedef SpBlock * SpBlockPtr; - -OSErr SGetCString(SpBlockPtr spBlkPtr); - -enum { - catDisplay = 0x0003, - typeVideo = 0x0001, - drSwApple = 0x0001, -}; - -enum { /* flags for spParamData */ - fall = 0, - foneslot = 1, - fnext = 2, -}; - - -OSErr SRsrcInfo(SpBlockPtr spBlkPtr); -OSErr SGetTypeSRsrc(SpBlockPtr spBlkPtr); -#endif - -typedef struct VDFlagRec -{ - char flag; -} VDFlagRec; -typedef VDFlagRec *VDFlagPtr; - -typedef struct VDParamBlock -{ - COMMON_PARAMS - short ioRefNum; - short csCode; - void* csParam; -} VDParamBlock; -typedef VDParamBlock *VDParamBlockPtr; - -extern void InitFS(short CntFCBs); -extern void InitEvents(short CntEvts); -extern void FInitQueue(void); -extern OSErr PBMountVol(ParmBlkPtr paramBlock) ; -extern OSErr PBGetVInfoSync(ParmBlkPtr paramBlock) ; - -#if defined(SCSI_SUPPORT) - -enum { - op_inc = 1, /* transfer data, increment buffer pointer */ - op_no_inc = 2, /* transfer data, don't increment pointer */ - op_add = 3, /* add long to address */ - op_mode = 4, /* move long to address */ - op_loop = 5, /* decrement counter and loop if > 0 */ - op_nop = 6, /* no operation */ - op_stop = 7, /* stop TIB execution */ - op_comp = 8, /* compare SCSI data with memory */ -}; - -typedef struct TIB { /* Transfer Instruction Block */ - short opcode; /* operation code */ - int param1; /* 1st parameter */ - int param2; /* 2nd parameter */ -} __attribute__((packed)) TIB_t; - -extern OSErr SCSIReset(void); -extern OSErr SCSIGet(void); -extern OSErr SCSISelect(short targetID); -extern OSErr SCSICmd(void *buffer, short count); -extern OSErr SCSIRead(void *tibPtr); -extern OSErr SCSIComplete(short *stat, short *message, unsigned long wait); -#endif /* SCSI_SUPPORT */ - diff --git a/second/keyboard.c b/second/keyboard.c index cdd6171..99c3fbd 100644 --- a/second/keyboard.c +++ b/second/keyboard.c @@ -6,9 +6,10 @@ #include -#include "lowmem.h" +#include +#include + #include "misc.h" -#include "glue.h" #include "keyboard.h" #include "vga.h" diff --git a/second/load.c b/second/load.c index c19faa6..bbe5b94 100644 --- a/second/load.c +++ b/second/load.c @@ -7,9 +7,12 @@ #include #include #include + +#include +#include + #include "bank.h" #include "misc.h" -#include "glue.h" #include "head.h" #include "load.h" #include "uncompress.h" diff --git a/second/lowmem.h b/second/lowmem.h deleted file mode 100644 index 756d299..0000000 --- a/second/lowmem.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * - * (c) 2004 Laurent Vivier - * - */ - -#define VIA1Base (*(unsigned long*)0x01D4) -#define SCCRd (*(unsigned long*)0x01d8) -#define SCCWr (*(unsigned long*)0x01dc) -#define ScrnBase (*(unsigned long*)0x0824) -#define ROMBase (*(short**)0x02ae) -#define HWCfgFlags (*(unsigned long*)0x0B22) -#define SCSIBase (*(unsigned long*)0x0C00) -#define ASCBase (*(unsigned long*)0x0CC0) -#define VIA2Base (*(unsigned long*)0x0CEC) -#define PMgrBase (*(unsigned long*)0x0D18) -#define UnivROMBits (*(unsigned long*)0x0DD4) -#define TimeVIADB (*(unsigned short*)0x0cea) -#define TimeDBRA (*(unsigned short*)0x0D00) -#define MemTop (*(unsigned long*)0x0108) -#define Time (*(unsigned long*)0x020C) -#define KeyLast (*(unsigned short*)0x0184) -#define KeyTime (*(unsigned long*)0x0186) -#define KeyRepTime (*(unsigned long*)0x018A) -#define Ticks (*(unsigned long*)0x016A) - -#define LMGetUnitTableEntryCount() (*(short*)0x1d2) -#define LMGetUTableBase() (*(unsigned long*)0x11c) diff --git a/second/memory.c b/second/memory.c deleted file mode 100644 index 888a251..0000000 --- a/second/memory.c +++ /dev/null @@ -1,25 +0,0 @@ -/* - * - * (c) 2004 Laurent Vivier - * - * portion from penguin booter - * - */ - -#include - -#include "misc.h" -#include "bank.h" -#include "memory.h" -#include "console.h" -#include "glue.h" - -void *malloc(size_t size) -{ - return NewPtr(size); -} - -void free(void *ptr) -{ - DisposePtr(ptr); -} diff --git a/second/memory.h b/second/memory.h deleted file mode 100644 index 8a3496c..0000000 --- a/second/memory.h +++ /dev/null @@ -1,5 +0,0 @@ -/* - * - * (c) 2004 Laurent Vivier - * - */ diff --git a/second/misc.h b/second/misc.h index cee8095..f2ef5b1 100644 --- a/second/misc.h +++ b/second/misc.h @@ -1,19 +1,12 @@ /* * - * (c) 2004 Laurent Vivier + * (c) 2004, 2005 Laurent Vivier * */ #ifndef __MISC_H__ #define __MISC_H__ -typedef unsigned char u_int8_t; -typedef signed char int8_t; -typedef unsigned short u_int16_t; -typedef signed short int16_t; -typedef unsigned int u_int32_t; -typedef signed int int32_t; - extern unsigned char *c2pstring(char* s); extern unsigned char *p2cstring(unsigned char* s); extern void memdump(unsigned char* addr, unsigned long size); diff --git a/second/printf.c b/second/printf.c deleted file mode 100644 index ac4cdbb..0000000 --- a/second/printf.c +++ /dev/null @@ -1,262 +0,0 @@ -/*- - * Copyright (c) 1986, 1988, 1991, 1993 - * The Regents of the University of California. All rights reserved. - * (c) UNIX System Laboratories, Inc. - * All or some portions of this file are derived from material licensed - * to the University of California by American Telephone and Telegraph - * Co. or Unix System Laboratories, Inc. and are reproduced herein with - * the permission of UNIX System Laboratories, Inc. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this -software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this -software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE -LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY -WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)subr_prf.c 8.3 (Berkeley) 1/21/94 - * - * - * Extracted vsprinf & adapted by BenH for MountX, Wed, June 3 1998. - * Added support for pascal strings. - */ - -#include -#include - -#include "misc.h" -#include "console.h" - -typedef unsigned long u_long; -typedef unsigned int u_int; -typedef unsigned char u_char; - -#define NBBY 8 - -static char *ksprintn(u_long ul, int base, int *lenp, int prec); - -int sprintf(char * s, const char * format, ...) -{ - va_list params; - int r; - - va_start(params, format); - r = vsprintf(s, format, params); - va_end(params); - - return r; -} - - -/* - * Scaled down version of sprintf(3). - */ -int -vsprintf(char *buf, const char *cfmt, va_list ap) -{ - register const char *fmt = cfmt; - register char *p, *bp; - register int ch, base; - u_long ul; - int lflag, tmp, width, pstring; - int prec, precspec; - char padc; - - for (bp = buf; ; ) { - padc = ' '; - width = 0; - prec = 0; - precspec = 0; - pstring = 0; - while ((ch = *(u_char *)fmt++) != '%') - if ((*bp++ = (char)ch) == '\0') - return ((bp - buf) - 1); - - lflag = 0; -reswitch: switch (ch = *(u_char *)fmt++) { - case '0': - padc = '0'; - goto reswitch; - case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - for (width = 0;; ++fmt) { - width = width * 10 + ch - '0'; - ch = *fmt; - if (ch < '0' || ch > '9') - break; - } - goto reswitch; - - case '#': - pstring = 1; - goto reswitch; - case '*': - width = va_arg(ap, int); - goto reswitch; - case '.': - precspec = 1; - if (*fmt == '*') { - prec = va_arg(ap, int); - ++fmt; - goto reswitch; - } - for (prec = 0;; ++fmt) { - ch = *fmt; - if (ch < '0' || ch > '9') - break; - prec = prec * 10 + ch - '0'; - } - goto reswitch; - case 'l': - lflag = 1; - goto reswitch; - /* case 'b': ... break; XXX */ - case 'c': - *bp++ = (char)va_arg(ap, int); - break; - /* case 'r': ... break; XXX */ - case 's': - p = va_arg(ap, char *); - if (pstring) - { - prec = precspec ? ((prec < *p) ? prec : *p) : *p; - p++; - precspec = 1; - } - while ((!precspec || (--prec >= 0)) && ((*bp = *p++) != 0)) - ++bp; - break; - case 'd': - ul = (unsigned long)(lflag ? va_arg(ap, long) : va_arg(ap, int)); - if ((long)ul < 0) { - *bp++ = (char)'-'; - ul = (unsigned long)(-(long)ul); - } - base = 10; - goto number; - break; - case 'o': - ul = lflag ? va_arg(ap, u_long) : va_arg(ap, -u_int); - base = 8; - goto number; - break; - case 'u': - ul = lflag ? va_arg(ap, u_long) : va_arg(ap, -u_int); - base = 10; - goto number; - break; - case 'p': - *bp++ = '0'; - *bp++ = 'x'; - ul = (u_long)va_arg(ap, void *); - base = 16; - goto number; - case 'x': - case 'X': - ul = lflag ? va_arg(ap, u_long) : va_arg(ap, -u_int); - base = 16; -number: p = ksprintn(ul, base, &tmp, prec); - if (width && (width -= tmp) > 0) - while (width--) - *bp++ = padc; - while ((ch = *p--) != 0) - *bp++ = (char)ch; - break; - default: - *bp++ = '%'; - if (lflag) - *bp++ = 'l'; - /* FALLTHROUGH */ - case '%': - *bp++ = (char)ch; - } - } -} - -/* - * Put a number (base <= 16) in a buffer in reverse order; return an - * optional length and a pointer to the NULL terminated (preceded?) - * buffer. - */ -static char * -ksprintn(u_long ul, int base, int *lenp, int prec) -{ /* A long in base 8, plus NULL. */ - static char buf[sizeof(long) * NBBY / 3 + 4]; - register char *p; - int i; - p = buf; - for(i=0;i 0 || ul != 0) && p < buf + sizeof(buf) - 1); - if (lenp) - *lenp = p - buf; - return (p); -} - - -static char __printf_buffer[2048]; - -int -printf(const char * format, ...) -{ - va_list args; - int len; - - va_start(args, format); - len = vsprintf(__printf_buffer, format, args); - va_end(args); - - if (len) - console_putstring(__printf_buffer); - - return len; -} - -#if __GNUC__==3 -int puts(const char * s) -{ - console_putstring(s); - console_putchar('\n'); - - return -1; -} - -int putchar (int c) -{ - return console_putchar(c); -} -#endif diff --git a/second/scsi.c b/second/scsi.c index ee03827..21a4dcb 100644 --- a/second/scsi.c +++ b/second/scsi.c @@ -7,9 +7,13 @@ #include #include #include + +#include +#include +#include + #include "bank.h" #include "misc.h" -#include "glue.h" #define COMPLETION_TIMEOUT 300 diff --git a/second/serial.c b/second/serial.c index cd0b269..e5b3471 100644 --- a/second/serial.c +++ b/second/serial.c @@ -7,8 +7,11 @@ #include #include +#include +#include +#include + #include "misc.h" -#include "glue.h" #include "head.h" #include "driver.h" diff --git a/second/serial.h b/second/serial.h index e000436..0ccddbd 100644 --- a/second/serial.h +++ b/second/serial.h @@ -4,7 +4,6 @@ * */ -#include "glue.h" #include "head.h" extern int setserial(short refNum, unsigned int bitrate, unsigned int datasize, diff --git a/second/vga.c b/second/vga.c index ab40a22..2caf3b0 100644 --- a/second/vga.c +++ b/second/vga.c @@ -6,10 +6,12 @@ #include +#include +#include +#include + #include "misc.h" -#include "glue.h" #include "vga.h" -#include "lowmem.h" QDGlobals qd;