mirror of
https://github.com/vivier/EMILE.git
synced 2025-04-08 04:39:14 +00:00
Move MacOS functions to libmacos
This commit is contained in:
parent
02e687a878
commit
9773bd7e68
25
libmacos/CloseDriver.c
Normal file
25
libmacos/CloseDriver.c
Normal file
@ -0,0 +1,25 @@
|
||||
/*
|
||||
*
|
||||
* (c) 2004,2005 Laurent Vivier <LaurentVivier@wanadoo.fr>
|
||||
*
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <macos/devices.h>
|
||||
|
||||
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;
|
||||
}
|
65
libmacos/Makefile
Normal file
65
libmacos/Makefile
Normal file
@ -0,0 +1,65 @@
|
||||
#
|
||||
# (c) 2005 Laurent Vivier <LaurentVivier@wanadoo.fr>
|
||||
#
|
||||
|
||||
TOP = $(shell pwd)
|
||||
CFLAGS = -nostdlib -nodefaultlibs -Wall -Werror -Wno-multichar -fpic -O2 -m68000 -Wa,-m68000 -Os
|
||||
CPPFLAGS = -I$(TOP) -DARCH_M68K
|
||||
|
||||
LIBRARY = libmacos.a
|
||||
|
||||
SOURCES = display_properties.S \
|
||||
CloseDriver.c OpenDriver.c SerGetBuf.c
|
||||
|
||||
HEADERS = libmacos.h \
|
||||
macos/devices.h macos/errors.h macos/events.h macos/files.h \
|
||||
macos/gestalt.h macos/header macos/init.h macos/lowmem.h \
|
||||
macos/memory.h macos/osutils.h macos/quickdraw.h macos/romdefs.h \
|
||||
macos/scsi.h macos/serial.h macos/slotmanager.h macos/traps.h \
|
||||
macos/types.h macos/video.h
|
||||
|
||||
DISTFILES = $(SOURCES) $(HEADERS)
|
||||
|
||||
OBJS = $(patsubst %.S,%.o,$(SOURCES:.c=.o))
|
||||
|
||||
all: $(LIBRARY)
|
||||
|
||||
$(LIBRARY): $(OBJS)
|
||||
$(AR) rc $@ $^
|
||||
|
||||
install: install-headers install-lib
|
||||
|
||||
install-lib:
|
||||
install -d $(DESTDIR)/$(PREFIX)/usr/lib/
|
||||
install $(LIBRARY) $(DESTDIR)/$(PREFIX)/usr/lib/$(LIBRARY)
|
||||
|
||||
install-headers:
|
||||
for file in $(HEADERS); do \
|
||||
dir=$$(dirname $$file); \
|
||||
if [ "$$dir" != "" ] ; then \
|
||||
mkdir -p $(DESTDIR)/$(PREFIX)/usr/include/$$dir; \
|
||||
fi; \
|
||||
cp -p $$file $(DESTDIR)/$(PREFIX)/usr/include/$$file; \
|
||||
done
|
||||
|
||||
uninstall: uninstall-lib uninstall-headers
|
||||
|
||||
uninstall-lib:
|
||||
rm -f $(DESTDIR)/$(PREFIX)/usr/lib/$(LIBRARY)
|
||||
|
||||
uninstall-headers:
|
||||
for file in $(HEADERS); do \
|
||||
rm -f $(DESTDIR)/$(PREFIX)/usr/include/$$file; \
|
||||
done
|
||||
|
||||
dist:
|
||||
for file in $(DISTFILES); do \
|
||||
dir=$$(dirname $$file); \
|
||||
if [ "$$dir" != "" ] ; then \
|
||||
mkdir -p $(DISTDIR)/libmacos/$$dir; \
|
||||
fi; \
|
||||
cp -p $$file $(DISTDIR)/libmacos/$$file; \
|
||||
done
|
||||
|
||||
clean:
|
||||
rm -f $(OBJS) $(LIBRARY)
|
35
libmacos/OpenDriver.c
Normal file
35
libmacos/OpenDriver.c
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
*
|
||||
* (c) 2005 Laurent Vivier <LaurentVivier@wanadoo.fr>
|
||||
*
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <macos/devices.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;
|
||||
}
|
25
libmacos/SerGetBuf.c
Normal file
25
libmacos/SerGetBuf.c
Normal file
@ -0,0 +1,25 @@
|
||||
/*
|
||||
*
|
||||
* (c) 2004,2005 Laurent Vivier <LaurentVivier@wanadoo.fr>
|
||||
*
|
||||
*/
|
||||
|
||||
#include <macos/devices.h>
|
||||
#include <macos/serial.h>
|
||||
|
||||
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;
|
||||
}
|
165
libmacos/display_properties.S
Normal file
165
libmacos/display_properties.S
Normal file
@ -0,0 +1,165 @@
|
||||
/*
|
||||
*
|
||||
* (c) 2004,2005 Laurent Vivier <LaurentVivier@wanadoo.fr>
|
||||
*
|
||||
*/
|
||||
|
||||
.chip 68000
|
||||
|
||||
.align 2
|
||||
|
||||
/* #include <ConditionalMacros.h>
|
||||
* #include <Quickdraw.h>
|
||||
*/
|
||||
|
||||
.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
|
10
libmacos/libmacos.h
Normal file
10
libmacos/libmacos.h
Normal file
@ -0,0 +1,10 @@
|
||||
/*
|
||||
*
|
||||
* (c) 2004, 2005 Laurent Vivier <LaurentVivier@wanadoo.fr>
|
||||
*
|
||||
*/
|
||||
|
||||
extern int glue_display_properties(unsigned long *base,
|
||||
unsigned long *row_bytes,
|
||||
unsigned long *width, unsigned long *height,
|
||||
unsigned long *depth, unsigned long *video);
|
123
libmacos/macos/devices.h
Normal file
123
libmacos/macos/devices.h
Normal file
@ -0,0 +1,123 @@
|
||||
/*
|
||||
*
|
||||
* (c) 2004,2005 Laurent Vivier <LaurentVivier@wanadoo.fr>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __MACOS_DEVICES_H__
|
||||
#define __MACOS_DEVICES_H__
|
||||
|
||||
#include <macos/traps.h>
|
||||
#include <macos/types.h>
|
||||
#include <macos/files.h>
|
||||
#include <macos/errors.h>
|
||||
|
||||
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;
|
||||
|
||||
#ifdef ARCH_M68K
|
||||
static inline OSErr PBCloseSync(ParmBlkPtr paramBlock)
|
||||
{
|
||||
register OSErr ret asm("%%d0");
|
||||
|
||||
asm("move.l %1, %%a0\n"
|
||||
Trap(_PBCloseSync)
|
||||
: "=d" (ret) : "g" (paramBlock) : UNPRESERVED_REGS);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline OSErr PBControlSync(ParmBlkPtr paramBlock)
|
||||
{
|
||||
register OSErr ret asm("%%d0");
|
||||
|
||||
asm("move.l %1, %%a0\n"
|
||||
Trap(_PBControlSync)
|
||||
: "=d" (ret) : "g" (paramBlock) : UNPRESERVED_REGS);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline OSErr PBOpenSync(ParmBlkPtr paramBlock)
|
||||
{
|
||||
register OSErr ret asm("%%d0");
|
||||
|
||||
asm("move.l %1, %%a0\n"
|
||||
Trap(_PBOpenSync)
|
||||
: "=d" (ret) : "g" (paramBlock) : UNPRESERVED_REGS);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline OSErr PBReadSync(ParamBlockRec_t* paramBlock)
|
||||
{
|
||||
register OSErr ret asm("%%d0");
|
||||
|
||||
asm("move.l %1, %%a0\n"
|
||||
Trap(_PBReadSync)
|
||||
: "=d" (ret) : "g" (paramBlock) : UNPRESERVED_REGS);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline OSErr PBStatusSync(ParamBlockRec_t* paramBlock)
|
||||
{
|
||||
register OSErr ret asm("%%d0");
|
||||
|
||||
asm("move.l %1, %%a0\n"
|
||||
Trap(_PBStatusSync)
|
||||
: "=d" (ret) : "g" (paramBlock) : UNPRESERVED_REGS);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline OSErr PBWriteSync(ParamBlockRec_t* paramBlock)
|
||||
{
|
||||
register OSErr ret asm("%%d0");
|
||||
|
||||
asm("move.l %1, %%a0\n"
|
||||
Trap(_PBWriteSync)
|
||||
: "=d" (ret) : "g" (paramBlock) : UNPRESERVED_REGS);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
extern OSErr OpenDriver(ConstStr255Param name, short *drvrRefNum);
|
||||
extern OSErr CloseDriver(short refNum);
|
||||
extern OSErr SerGetBuf(short refNum, long *count);
|
||||
#endif /* ARCH_M68K */
|
||||
#endif /* __MACOS_DEVICES_H__ */
|
45
libmacos/macos/errors.h
Normal file
45
libmacos/macos/errors.h
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
*
|
||||
* (c) 2004,2005 Laurent Vivier <LaurentVivier@wanadoo.fr>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __MACOS_ERRORS_H__
|
||||
#define __MACOS_ERRORS_H__
|
||||
|
||||
#include <macos/traps.h>
|
||||
|
||||
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,
|
||||
};
|
||||
|
||||
#ifdef ARCH_M68K
|
||||
static inline void SysError(short errorCode)
|
||||
{
|
||||
asm("move.l %0, %%d0\n"
|
||||
Trap(_SysError)
|
||||
:: "g" (errorCode) : "%%d0", UNPRESERVED_REGS);
|
||||
}
|
||||
#endif /* ARCH_M68K */
|
||||
#endif /* __MACOS_ERRORS_H__ */
|
20
libmacos/macos/events.h
Normal file
20
libmacos/macos/events.h
Normal file
@ -0,0 +1,20 @@
|
||||
/*
|
||||
*
|
||||
* (c) 2004,2005 Laurent Vivier <LaurentVivier@wanadoo.fr>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __MACOS_EVENTS_H__
|
||||
#define __MACOS_EVENTS_H__
|
||||
|
||||
#include <macos/traps.h>
|
||||
|
||||
typedef u_int32_t KeyMap[4];
|
||||
|
||||
static inline void GetKeys(KeyMap theKeys)
|
||||
{
|
||||
asm("move.l %0, -(%%sp)\n"
|
||||
Trap(_GetKeys)
|
||||
:: "g" (theKeys) : "%%d0", UNPRESERVED_REGS );
|
||||
}
|
||||
#endif /* __MACOS_EVENTS_H__ */
|
138
libmacos/macos/files.h
Normal file
138
libmacos/macos/files.h
Normal file
@ -0,0 +1,138 @@
|
||||
/*
|
||||
*
|
||||
* (c) 2004,2005 Laurent Vivier <LaurentVivier@wanadoo.fr>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __MACOS_FILES_H__
|
||||
#define __MACOS_FILES_H__
|
||||
|
||||
#include <macos/traps.h>
|
||||
|
||||
enum {
|
||||
fsAtMark = 0,
|
||||
fsFromStart = 1,
|
||||
fsFromLEOF = 2,
|
||||
fsFromMark = 3
|
||||
};
|
||||
|
||||
/* ParamBlockRec Structure: "Inside Macintosh: Files", p. 2-87 */
|
||||
|
||||
#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 }
|
||||
|
||||
/* 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 */
|
||||
};
|
||||
|
||||
struct DrvQEl {
|
||||
void* qLink;
|
||||
int16_t qType;
|
||||
int16_t dQDrive;
|
||||
int16_t dQRefNum;
|
||||
int16_t dQFSID;
|
||||
u_int16_t dQDrvSz;
|
||||
u_int16_t dQDrvSz2;
|
||||
};
|
||||
typedef struct DrvQEl DrvQEl;
|
||||
typedef DrvQEl * DrvQElPtr;
|
||||
|
||||
#ifdef ARCH_M68K
|
||||
static inline void FInitQueue(void)
|
||||
{
|
||||
asm(Trap(_FInitQueue) ::: "%%d0", UNPRESERVED_REGS);
|
||||
}
|
||||
|
||||
static inline OSErr PBGetVInfoSync(ParmBlkPtr paramBlock)
|
||||
{
|
||||
register OSErr ret asm("%%d0");
|
||||
|
||||
asm("move.l %1, %%a0\n"
|
||||
Trap(_GetVolInfo)
|
||||
: "=g" (ret) : "g" (paramBlock) : UNPRESERVED_REGS);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline OSErr PBMountVol(ParmBlkPtr paramBlock)
|
||||
{
|
||||
register OSErr ret asm("%%d0");
|
||||
|
||||
asm("move.l %1, %%a0\n"
|
||||
Trap(_MountVol)
|
||||
: "=g" (ret) : "g" (paramBlock) : UNPRESERVED_REGS);
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif /* ARCH_M68K */
|
||||
#endif /* __MACOS_FILES_H__ */
|
223
libmacos/macos/gestalt.h
Normal file
223
libmacos/macos/gestalt.h
Normal file
@ -0,0 +1,223 @@
|
||||
/*
|
||||
*
|
||||
* (c) 2004,2005 Laurent Vivier <LaurentVivier@wanadoo.fr>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __MACOS_GESTALT_H__
|
||||
#define __MACOS_GESTALT_H__
|
||||
|
||||
#include <macos/traps.h>
|
||||
|
||||
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
|
||||
};
|
||||
|
||||
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? */
|
||||
};
|
||||
|
||||
#ifdef ARCH_M68K
|
||||
static inline OSErr Gestalt(OSType selector, long * response)
|
||||
{
|
||||
register OSErr ret asm("%%d0");
|
||||
|
||||
asm("move.l %2, %%d0\n"
|
||||
Trap(_Gestalt)
|
||||
" move.l %%a0, %1\n"
|
||||
: "=d" (ret), "=m" (*response) : "g" (selector) : UNPRESERVED_REGS);
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif /* ARCH_M68K */
|
||||
#endif /* __MACOS_GESTALT_H__ */
|
25
libmacos/macos/init.h
Normal file
25
libmacos/macos/init.h
Normal file
@ -0,0 +1,25 @@
|
||||
/*
|
||||
*
|
||||
* (c) 2004,2005 Laurent Vivier <LaurentVivier@wanadoo.fr>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __MACOS_INIT_H__
|
||||
#define __MACOS_INIT_H__
|
||||
|
||||
#include <macos/traps.h>
|
||||
|
||||
statis inline void InitEvents(short CntEvts)
|
||||
{
|
||||
asm("move.l %0, %%d0\n"
|
||||
Trap(_InitEvents)
|
||||
:: "g" (CntEvts) : "%%d0", UNPRESERVED_REGS);
|
||||
}
|
||||
|
||||
static inline void InitFS(short CntFCBs)
|
||||
{
|
||||
asm("move.l %0, %%d0\n"
|
||||
Trap(_InitFs)
|
||||
:: "g" (CntFCBs) : "%%d0", UNPRESERVED_REGS);
|
||||
}
|
||||
#endif /* __MACOS_INIT_H__ */
|
35
libmacos/macos/lowmem.h
Normal file
35
libmacos/macos/lowmem.h
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
*
|
||||
* (c) 2004, 2005 Laurent Vivier <LaurentVivier@wanadoo.fr>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __MACOS_LOWMEM_H__
|
||||
#define __MACOS_LOWMEM_H__
|
||||
|
||||
#include <macos/osutils.h>
|
||||
|
||||
#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)
|
||||
#define LMGetDrvQHdr() ( (QHdrPtr) 0x0308)
|
||||
#endif /* __MACOS_LOWMEM_H__ */
|
30
libmacos/macos/memory.h
Normal file
30
libmacos/macos/memory.h
Normal file
@ -0,0 +1,30 @@
|
||||
/*
|
||||
*
|
||||
* (c) 2004,2005 Laurent Vivier <LaurentVivier@wanadoo.fr>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __MACOS_MEMORY_H__
|
||||
#define __MACOS_MEMORY_H__
|
||||
|
||||
#include <macos/traps.h>
|
||||
|
||||
static inline void DisposePtr(void* ptr)
|
||||
{
|
||||
asm("move.l %0, %%a0\n"
|
||||
Trap(_DisposePtr)
|
||||
:: "g" (ptr) : "%%d0", UNPRESERVED_REGS);
|
||||
}
|
||||
|
||||
static inline void* NewPtr(unsigned long byteCount)
|
||||
{
|
||||
register void* ptr;
|
||||
|
||||
asm("move.l %1, %%d0\n"
|
||||
Trap(_NewPtr)
|
||||
" move.l %%a0, %0\n"
|
||||
: "=g" (ptr) : "g" (byteCount) : "%%d0", UNPRESERVED_REGS);
|
||||
|
||||
return ptr;
|
||||
}
|
||||
#endif /* __MACOS_MEMORY_H__ */
|
39
libmacos/macos/osutils.h
Normal file
39
libmacos/macos/osutils.h
Normal file
@ -0,0 +1,39 @@
|
||||
/*
|
||||
*
|
||||
* (c) 2004,2005 Laurent Vivier <LaurentVivier@wanadoo.fr>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __MACOS_OSUTILS_H__
|
||||
#define __MACOS_OSUTILS_H__
|
||||
|
||||
#include <macos/types.h>
|
||||
#include <macos/traps.h>
|
||||
|
||||
struct QHdr {
|
||||
int16_t qFlags;
|
||||
void* qHead;
|
||||
void* qTail;
|
||||
};
|
||||
typedef struct QHdr QHdr;
|
||||
typedef QHdr * QHdrPtr;
|
||||
|
||||
struct MachineLocation
|
||||
{
|
||||
int32_t latitude;
|
||||
int32_t longitude;
|
||||
union
|
||||
{
|
||||
int8_t dlsDelta;
|
||||
int32_t gmtDelta;
|
||||
} u;
|
||||
};
|
||||
typedef struct MachineLocation MachineLocation;
|
||||
|
||||
static inline void ReadLocation(MachineLocation * loc)
|
||||
{
|
||||
asm("move.l %0, %%a0\n"
|
||||
XPRam(_ReadLocation)
|
||||
:: "g" (loc) : "%%d0", UNPRESERVED_REGS);
|
||||
}
|
||||
#endif /* __MACOS_OSUTILS_H__ */
|
64
libmacos/macos/quickdraw.h
Normal file
64
libmacos/macos/quickdraw.h
Normal file
@ -0,0 +1,64 @@
|
||||
/*
|
||||
*
|
||||
* (c) 2004,2005 Laurent Vivier <LaurentVivier@wanadoo.fr>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __MACOS_QUICKDRAW_H__
|
||||
#define __MACOS_QUICKDRAW_H__
|
||||
#include <macos/traps.h>
|
||||
|
||||
|
||||
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;
|
||||
|
||||
static inline void InitGraf(void * port)
|
||||
{
|
||||
asm("move.l %0, -(%%sp)\n"
|
||||
Trap(_InitGraf)
|
||||
" addq.l #4, %%sp"
|
||||
:: "g" (port) : "%%d0", UNPRESERVED_REGS);
|
||||
}
|
||||
#endif /* __MACOS_QUICKDRAW_H__ */
|
14
libmacos/macos/romdefs.h
Normal file
14
libmacos/macos/romdefs.h
Normal file
@ -0,0 +1,14 @@
|
||||
/*
|
||||
*
|
||||
* (c) 2004,2005 Laurent Vivier <LaurentVivier@wanadoo.fr>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __MACOS_ROMDEFS_H__
|
||||
#define __MACOS_ROMDEFS_H__
|
||||
enum {
|
||||
catDisplay = 0x0003,
|
||||
typeVideo = 0x0001,
|
||||
drSwApple = 0x0001,
|
||||
};
|
||||
#endif /* __MACOS_ROMDEFS_H__ */
|
102
libmacos/macos/scsi.h
Normal file
102
libmacos/macos/scsi.h
Normal file
@ -0,0 +1,102 @@
|
||||
/*
|
||||
*
|
||||
* (c) 2004,2005 Laurent Vivier <LaurentVivier@wanadoo.fr>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __MACOS_SCSI_H__
|
||||
#define __MACOS_SCSI_H__
|
||||
#include <macos/traps.h>
|
||||
|
||||
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;
|
||||
|
||||
static inline OSErr SCSICmd(void* buffer, short count)
|
||||
{
|
||||
register OSErr ret asm("%%d0");
|
||||
|
||||
asm("move.l %2, %%d0\n"
|
||||
" clr.w -(%%sp)\n"
|
||||
" move.l %1, -(%%sp)\n"
|
||||
" move.w %d0, -(%%sp)\n"
|
||||
SCSIDispatch(_SCSICmd)
|
||||
: "=d" (ret) : "g" (buffer), "g" (count) : UNPRESERVED_REGS );
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline OSErr SCSIComplete(short *stat, short *message, unsigned long wait)
|
||||
{
|
||||
register OSErr ret asm("%%d0");
|
||||
|
||||
asm("clr.w -(%%sp)\n"
|
||||
" move.l %0, -(%%sp)\n"
|
||||
" move.l %1, -(%%sp)\n"
|
||||
" move.l %2, -(%%sp)\n"
|
||||
SCSIDispatch(_SCSIComplete)
|
||||
: "=d" (ret) : "g" (stat), "g" (message), "g" (wait) : UNPRESERVED_REGS );
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline OSErr SCSIGet(void)
|
||||
{
|
||||
register OSErr ret asm("%%d0");
|
||||
|
||||
asm("clr.w -(%%sp)\n"
|
||||
SCSIDispatch(_SCSIGet)
|
||||
: "=d" (ret) :: UNPRESERVED_REGS );
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline OSErr SCSIRead(void *tibPtr)
|
||||
{
|
||||
register OSErr ret asm("%%d0");
|
||||
|
||||
asm("clr.w -(%%sp)\n"
|
||||
" move.l %1, -(%%sp)\n"
|
||||
SCSIDispatch(_SCSIRead)
|
||||
: "=d" (ret) : "g" (tibPtr) : UNPRESERVED_REGS );
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline OSErr SCSIReset(void)
|
||||
{
|
||||
register OSErr ret asm("%%d0");
|
||||
|
||||
asm("clr.w -(%%sp)\n"
|
||||
SCSIDispatch(_SCSIReset)
|
||||
: "=d" (ret) :: UNPRESERVED_REGS );
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline OSErr SCSISelect(short targetID)
|
||||
{
|
||||
register OSErr ret asm("%%d0");
|
||||
|
||||
asm("move.w %1, %%d0\n"
|
||||
" clr.w -(%%sp)\n"
|
||||
" move.w %%d0, -(%%sp)\n"
|
||||
SCSIDispatch(_SCSISelect)
|
||||
: "=d" (ret) : "g" (targetID) : UNPRESERVED_REGS );
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif /* __MACOS_SCSI_H__ */
|
81
libmacos/macos/serial.h
Normal file
81
libmacos/macos/serial.h
Normal file
@ -0,0 +1,81 @@
|
||||
/*
|
||||
*
|
||||
* (c) 2004,2005 Laurent Vivier <LaurentVivier@wanadoo.fr>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __MACOS_SERIAL_H__
|
||||
#define __MACOS_SERIAL_H__
|
||||
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
|
||||
};
|
||||
|
||||
enum {
|
||||
kSERDInputCount = 2, /* get available characters count (SerGetBuf) */
|
||||
kSERDStatus = 8, /* get status information (SerStatus) */
|
||||
kSERDVersion = 9, /* get driver version */
|
||||
};
|
||||
extern OSErr SerGetBuf(short refNum, long *count);
|
||||
#endif /* __MACOS_SERIAL_H__ */
|
88
libmacos/macos/slotmanager.h
Normal file
88
libmacos/macos/slotmanager.h
Normal file
@ -0,0 +1,88 @@
|
||||
/*
|
||||
*
|
||||
* (c) 2004,2005 Laurent Vivier <LaurentVivier@wanadoo.fr>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __MACOS_SLOTMANAGER_H__
|
||||
#define __MACOS_SLOTMANAGER_H__
|
||||
#include <macos/traps.h>
|
||||
|
||||
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;
|
||||
|
||||
enum { /* flags for spParamData */
|
||||
fall = 0,
|
||||
foneslot = 1,
|
||||
fnext = 2,
|
||||
};
|
||||
|
||||
static inline OSErr SGetCString(SpBlockPtr spBlkPtr)
|
||||
{
|
||||
register OSErr ret asm("%%d0");
|
||||
|
||||
asm("move.l %1, %%a0\n"
|
||||
SlotManager(_SGetCString)
|
||||
: "=g" (ret) : "g" (spBlkPtr) : UNPRESERVED_REGS);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline OSErr SGetTypeSRsrc(SpBlockPtr spBlkPtr)
|
||||
{
|
||||
register OSErr ret asm("%%d0");
|
||||
|
||||
asm("move.l %1, %%a0\n"
|
||||
SlotManager(_SGetTypeSRsrc)
|
||||
: "=g" (ret) : "g" (spBlkPtr) : UNPRESERVED_REGS);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline OSErr SRsrcInfo(SpBlockPtr spBlkPtr)
|
||||
{
|
||||
register OSErr ret asm("%%d0");
|
||||
|
||||
asm("move.l %1, %%a0\n"
|
||||
SlotManager(_SRsrcInfo)
|
||||
: "=g" (ret) : "g" (spBlkPtr) : UNPRESERVED_REGS);
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif /* __MACOS_SLOTMANAGER_H__ */
|
87
libmacos/macos/traps.h
Normal file
87
libmacos/macos/traps.h
Normal file
@ -0,0 +1,87 @@
|
||||
/*
|
||||
*
|
||||
* (c) 2004,2005 Laurent Vivier <LaurentVivier@wanadoo.fr>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __MACOS_TRAPS_H__
|
||||
#define __MACOS_TRAPS_H__
|
||||
#define _DisposePtr 0xA01F
|
||||
#define _FInitQueue 0xA016
|
||||
#define _Gestalt 0xA1AD
|
||||
#define _GetKeys 0xA976
|
||||
#define _InitEvents 0xA06D
|
||||
#define _InitFS 0xA06C
|
||||
#define _InitGraf 0xA86E
|
||||
#define _NewPtr 0xA11E
|
||||
#define _NewPtrClear 0xA31E
|
||||
#define _PBCloseSync 0xA001
|
||||
#define _PBControlSync 0xA004
|
||||
#define _GetVolInfo 0xA007
|
||||
#define _MountVol 0xA00F
|
||||
#define _PBOpenSync 0xA000
|
||||
#define _PBReadSync 0xA002
|
||||
#define _PBWriteSync 0xA003
|
||||
#define _PBStatusSync 0xA005
|
||||
#define _ReadXPRam 0xA051
|
||||
#define _SlotManager 0xA06E
|
||||
#define _SCSIDispatch 0xA815
|
||||
#define _SysError 0xA9C9
|
||||
|
||||
/*
|
||||
* Inside Macintosh Volume I, I-94: Register Saving Conventions */
|
||||
|
||||
#define UNPRESERVED_REGS "%%a0", "%%a1", "%%d1", "%%d2", "%%sp"
|
||||
|
||||
#define _Trap(a) #a
|
||||
#define Trap(a) " dc.w "_Trap(a)" /* "#a" */\n"
|
||||
|
||||
/*
|
||||
* XPRam Selectors
|
||||
*
|
||||
*/
|
||||
|
||||
#define _ReadLocation 0x000C00E4
|
||||
|
||||
#define XPRamSelector(a) " move.l #"#a", %%d0"
|
||||
|
||||
#define XPRam(selector) \
|
||||
XPRamSelector(selector)" /* "#selector" */\n" \
|
||||
Trap(_ReadXPRam)
|
||||
|
||||
/*
|
||||
* SlotManager selectors
|
||||
*
|
||||
*/
|
||||
|
||||
#define _SGetCString 0x0003
|
||||
#define _SGetTypeSRsrc 0x000C
|
||||
#define _SRsrcInfo 0x0016
|
||||
|
||||
#define SlotManagerSelector(a) " move.l #"#a", %%d0"
|
||||
|
||||
#define SlotManager(selector)" /* "#selector" */\n" \
|
||||
SlotManagerSelector(selector) \
|
||||
Trap(_SlotManager)
|
||||
|
||||
/*
|
||||
* SCSI dispatch selectors
|
||||
*
|
||||
*/
|
||||
|
||||
#define _SCSIReset 0x0000
|
||||
#define _SCSIGet 0x0001
|
||||
#define _SCSISelect 0x0002
|
||||
#define _SCSICmd 0x0003
|
||||
#define _SCSIComplete 0x0004
|
||||
#define _SCSIRead 0x0005
|
||||
#define _SCSIWrite 0x0006
|
||||
|
||||
#define SCSIDispatchSelector(a) " move.w #"#a", -(%%sp)"
|
||||
|
||||
#define SCSIDispatch(selector) \
|
||||
SCSIDispatchSelector(selector)" /* "#selector" */\n" \
|
||||
Trap(_SCSIDispatch) \
|
||||
" move.w (%%sp)+, %%d0\n" \
|
||||
" ext.l %%d0\n"
|
||||
#endif /* __MACOS_TRAPS_H__ */
|
46
libmacos/macos/types.h
Normal file
46
libmacos/macos/types.h
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
*
|
||||
* (c) 2004,2005 Laurent Vivier <LaurentVivier@wanadoo.fr>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __MACOS_TYPES_H__
|
||||
#define __MACOS_TYPES_H__
|
||||
|
||||
#ifdef ARCH_M68K
|
||||
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;
|
||||
#endif /* ARCH_M68K */
|
||||
|
||||
typedef int16_t OSErr;
|
||||
typedef unsigned long FourCharCode;
|
||||
typedef FourCharCode OSType;
|
||||
typedef unsigned char Str255[256];
|
||||
typedef const unsigned char * ConstStr255Param;
|
||||
typedef unsigned char Str27[28];
|
||||
|
||||
enum {
|
||||
false = 0,
|
||||
true = 1
|
||||
};
|
||||
|
||||
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;
|
||||
#endif /* __MACOS_TYPES_H__ */
|
23
libmacos/macos/video.h
Normal file
23
libmacos/macos/video.h
Normal file
@ -0,0 +1,23 @@
|
||||
/*
|
||||
*
|
||||
* (c) 2004,2005 Laurent Vivier <LaurentVivier@wanadoo.fr>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __MACOS_VIDEO_H__
|
||||
#define __MACOS_VIDEO_H__
|
||||
typedef struct VDFlagRec
|
||||
{
|
||||
char flag;
|
||||
} VDFlagRec;
|
||||
typedef VDFlagRec *VDFlagPtr;
|
||||
|
||||
typedef struct VDParamBlock
|
||||
{
|
||||
COMMON_PARAMS
|
||||
short ioRefNum;
|
||||
short csCode;
|
||||
void* csParam;
|
||||
} VDParamBlock;
|
||||
typedef VDParamBlock *VDParamBlockPtr;
|
||||
#endif /* __MACOS_VIDEO_H__ */
|
Loading…
x
Reference in New Issue
Block a user