1 |
|
/* |
2 |
|
* macos_util.h - MacOS definitions/utility functions |
3 |
|
* |
4 |
< |
* SheepShaver (C) 1997-2002 Christian Bauer and Marc Hellwig |
4 |
> |
* SheepShaver (C) 1997-2008 Christian Bauer and Marc Hellwig |
5 |
|
* |
6 |
|
* This program is free software; you can redistribute it and/or modify |
7 |
|
* it under the terms of the GNU General Public License as published by |
22 |
|
#define MACOS_UTIL_H |
23 |
|
|
24 |
|
#include "cpu_emulation.h" |
25 |
+ |
#include "thunks.h" |
26 |
+ |
#include <stddef.h> |
27 |
|
|
28 |
|
|
29 |
|
/* |
305 |
|
typedef uint32 ProcInfoType; |
306 |
|
typedef int8 ISAType; |
307 |
|
typedef uint16 RoutineFlagsType; |
308 |
< |
typedef long (*ProcPtr)(); |
308 |
> |
typedef uint32 ProcPtr; |
309 |
|
typedef uint8 RDFlagsType; |
310 |
|
|
311 |
|
struct RoutineRecord { |
329 |
|
RoutineRecord routineRecords[1]; /* The individual routines */ |
330 |
|
}; |
331 |
|
|
332 |
< |
#define BUILD_PPC_ROUTINE_DESCRIPTOR(procInfo, procedure) \ |
333 |
< |
{ \ |
334 |
< |
0xAAFE, /* Mixed Mode A-Trap */ \ |
335 |
< |
7, /* version */ \ |
336 |
< |
0, /* RD Flags - not dispatched */ \ |
337 |
< |
0, /* reserved 1 */ \ |
338 |
< |
0, /* reserved 2 */ \ |
339 |
< |
0, /* selector info */ \ |
340 |
< |
0, /* number of routines */ \ |
341 |
< |
{ /* It's an array */ \ |
342 |
< |
{ /* It's a struct */ \ |
343 |
< |
(procInfo), /* the ProcInfo */ \ |
344 |
< |
0, /* reserved */ \ |
345 |
< |
1, /* ISA and RTA */ \ |
344 |
< |
0 | /* Flags - it's absolute addr */\ |
345 |
< |
0 | /* It's prepared */ \ |
346 |
< |
4, /* Always use native ISA */ \ |
347 |
< |
(ProcPtr)(procedure), /* the procedure */ \ |
348 |
< |
0, /* reserved */ \ |
349 |
< |
0 /* Not dispatched */ \ |
350 |
< |
} \ |
351 |
< |
} \ |
332 |
> |
struct SheepRoutineDescriptor |
333 |
> |
: public SheepVar |
334 |
> |
{ |
335 |
> |
SheepRoutineDescriptor(ProcInfoType procInfo, uint32 procedure) |
336 |
> |
: SheepVar(sizeof(RoutineDescriptor)) |
337 |
> |
{ |
338 |
> |
const uintptr desc = addr(); |
339 |
> |
Mac_memset(desc, 0, sizeof(RoutineDescriptor)); |
340 |
> |
WriteMacInt16(desc + offsetof(RoutineDescriptor, goMixedModeTrap), 0xAAFE); |
341 |
> |
WriteMacInt8 (desc + offsetof(RoutineDescriptor, version), 7); |
342 |
> |
WriteMacInt32(desc + offsetof(RoutineDescriptor, routineRecords) + offsetof(RoutineRecord, procInfo), procInfo); |
343 |
> |
WriteMacInt8 (desc + offsetof(RoutineDescriptor, routineRecords) + offsetof(RoutineRecord, ISA), 1); |
344 |
> |
WriteMacInt16(desc + offsetof(RoutineDescriptor, routineRecords) + offsetof(RoutineRecord, routineFlags), 0 | 0 | 4); |
345 |
> |
WriteMacInt32(desc + offsetof(RoutineDescriptor, routineRecords) + offsetof(RoutineRecord, procDescriptor), procedure); |
346 |
|
} |
347 |
+ |
}; |
348 |
|
|
349 |
|
|
350 |
|
// Functions |
353 |
|
extern int FindFreeDriveNumber(int num); // Find first free drive number, starting at "num" |
354 |
|
extern void MountVolume(void *fh); // Mount volume with given file handle (see sys.h) |
355 |
|
extern void FileDiskLayout(loff_t size, uint8 *data, loff_t &start_byte, loff_t &real_size); // Calculate disk image file layout given file size and first 256 data bytes |
356 |
< |
extern void *FindLibSymbol(char *lib, char *sym); // Find symbol in shared library |
356 |
> |
extern uint32 FindLibSymbol(char *lib, char *sym); // Find symbol in shared library |
357 |
|
extern void InitCallUniversalProc(void); // Init CallUniversalProc() |
358 |
|
extern long CallUniversalProc(void *upp, uint32 info); // CallUniversalProc() |
359 |
|
extern uint32 TimeToMacTime(time_t t); // Convert time_t value to MacOS time |
360 |
+ |
extern uint32 Mac_sysalloc(uint32 size); // Allocate block in MacOS system heap zone |
361 |
+ |
extern void Mac_sysfree(uint32 addr); // Release block occupied by the nonrelocatable block p |
362 |
|
|
363 |
|
// Construct four-character-code from string |
364 |
|
#define FOURCC(a,b,c,d) (((uint32)(a) << 24) | ((uint32)(b) << 16) | ((uint32)(c) << 8) | (uint32)(d)) |