home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga MA Magazine 1998 #6
/
amigamamagazinepolishissue1998.iso
/
coders
/
jËzyki_programowania
/
oberon
/
system
/
amigaexec.mod
(
.txt
)
< prev
next >
Wrap
Oberon Text
|
1977-12-31
|
9KB
|
338 lines
Syntax10.Scn.Fnt
Syntax10i.Scn.Fnt
Syntax10b.Scn.Fnt
MODULE AmigaExec; (* SHML/CN 15. Mar 93, 23 Jun 94, RD 25 Dec 95 *)
IMPORT SYSTEM, A := AmigaBase;
CONST
(* Flags for AllocMem *)
memChip*=1;
memClear*=16;
(* IORequest.command: *)
invalid * = 0;
reset * = 1;
read * = 2;
write * = 3;
update * = 4;
clear * = 5;
stop * = 6;
start * = 7;
flush * = 8;
nonstd * = 9;
execBase:LONGINT;
execVersion-:INTEGER;
PROC*=PROCEDURE;
TaskPtr*=LONGINT;
UnitPtr* = LONGINT;
IORequestPtr * = LONGINT;
IOStdReqPtr * = LONGINT;
NodePtr*=LONGINT;
Node*=RECORD
succ*:NodePtr;
pred*:NodePtr;
type*:SHORTINT;
pri*:SHORTINT;
name*:LONGINT
END;
List*=RECORD
head*:NodePtr;
tail*:NodePtr;
tailPred*:NodePtr;
type*:SHORTINT;
pad*:SHORTINT
END;
MinNodePtr*=LONGINT;
MinNode*=RECORD
succ*:MinNodePtr;
pred*:MinNodePtr
END;
MinList*=RECORD
head*,tail*,tailPred*:MinNodePtr
END;
MsgPortPtr*=LONGINT;
MsgPort*=RECORD
node*:Node;
flags*:SHORTINT;
sigBit*:SHORTINT;
sigTask*:TaskPtr;
msgList*:List
END;
Unit * = RECORD
msgPort * : MsgPort; (* queue for unprocessed messages *)
(* instance of msgport is recommended *)
flags * : SHORTINT;
pad * : SHORTINT;
openCnt * : INTEGER; (* number of active opens *)
END;
SemaphoreRequest*=RECORD
link*:MinNode;
waiter*:TaskPtr
END;
SignalSemaphore*=RECORD
link*:Node;
nestCount*:INTEGER;
waitQueue*:MinList;
multipleLink*:SemaphoreRequest;
owner*:TaskPtr;
queueCount*:INTEGER
END;
Message*=RECORD
node*:Node;
replyPort*:MsgPortPtr;
length*:INTEGER
END;
MessagePtr*=LONGINT;
Task*=RECORD
node:Node;
flags:SHORTINT;
state:SHORTINT;
idNestCnt:SHORTINT;
tdNestCnt:SHORTINT;
sigAlloc:SET;
sigWait:SET;
sigRecvd:SET;
sigExcept:SET;
trapAlloc:INTEGER;
trapAble:INTEGER;
exceptData:LONGINT;
exceptCode:LONGINT;
trapData:LONGINT;
trapCode:LONGINT;
spReg:LONGINT;
spLower:LONGINT;
spUpper:LONGINT;
switch:LONGINT;
launch:LONGINT;
memEntry:List;
userData:LONGINT
END;
Library*=RECORD
node*:Node;
flags*:SHORTINT;
pad*:SHORTINT;
negSize*:INTEGER;
posSize*:INTEGER;
version*:INTEGER;
revision*:INTEGER;
idString*:LONGINT;
sum*:LONGINT;
openCnt*:INTEGER
END;
LibraryPtr*=LONGINT;
DevicePtr*=LONGINT;
IORequest * = RECORD
message * : Message;
device * : DevicePtr; (* device node pointer *)
unit * : UnitPtr; (* unit (driver private)*)
command * : INTEGER; (* device command *)
flags * : SHORTINT;
error * : SHORTINT; (* error or warning num *)
END;
IOStdReq * = RECORD
message * : Message;
device * : DevicePtr; (* device node pointer *)
unit * : UnitPtr; (* unit (driver private)*)
command * : INTEGER; (* device command *)
flags * : SHORTINT;
error * : SHORTINT; (* error or warning num *)
actual * : LONGINT; (* actual number of bytes transferred *)
length * : LONGINT; (* requested number bytes transferred*)
data * : LONGINT; (* points to data area *)
offset * : LONGINT; (* offset for block structured devices *)
END;
MemPoolPtr*=LONGINT;
PROCEDURE AllocMem*(size:LONGINT; reqs:SET):LONGINT;
r:A.Regs;
BEGIN
r.d[0]:=size;
r.d[1]:=SYSTEM.VAL(LONGINT,reqs);
A.LibCall(execBase,-198,r);
RETURN r.d[0]
END AllocMem;
PROCEDURE FreeMem*(adr,size:LONGINT);
r:A.Regs;
BEGIN
r.a[1]:=adr;
r.d[0]:=size;
A.LibCall(execBase,-210,r)
END FreeMem;
PROCEDURE CopyMemAPTR*(source,dest,size:LONGINT);
r:A.Regs;
BEGIN
r.a[0]:=source;
r.a[1]:=dest;
r.d[0]:=size;
A.LibCall(execBase,-624,r)
END CopyMemAPTR;
PROCEDURE Forbid*();
r:A.Regs;
BEGIN
A.LibCall(execBase, -132, r)
END Forbid;
PROCEDURE FindTask*(name:LONGINT):TaskPtr;
r:A.Regs;
BEGIN
r.a[1]:=name;
A.LibCall(execBase,-294,r);
RETURN r.d[0]
END FindTask;
PROCEDURE Permit*();
r:A.Regs;
BEGIN
A.LibCall(execBase, -138, r)
END Permit;
PROCEDURE SetTaskPri*(task: TaskPtr; pri: LONGINT): LONGINT;
r:A.Regs;
BEGIN
r.a[1]:=task;
r.d[0]:=pri;
A.LibCall(execBase,-300,r);
RETURN r.d[0]
END SetTaskPri;
PROCEDURE OpenLibrary*(libName:ARRAY OF CHAR; version:LONGINT):LONGINT;
r:A.Regs;
BEGIN
r.a[1]:=SYSTEM.ADR(libName);
r.d[0]:=version;
A.LibCall(execBase,-552,r);
RETURN r.d[0]
END OpenLibrary;
PROCEDURE OpenDevice*(devName:ARRAY OF CHAR; unit: LONGINT;
ioRequest: MessagePtr; flags: SET): SHORTINT;
r:A.Regs;
BEGIN
r.a[0]:=SYSTEM.ADR(devName);
r.d[0]:=unit;
r.a[1]:=SYSTEM.VAL(LONGINT,ioRequest);
r.d[1]:=SYSTEM.VAL(LONGINT,flags);
A.LibCall(execBase,-444,r);
RETURN SHORT(SHORT(r.d[0]))
END OpenDevice;
PROCEDURE WaitPort*(port: MsgPortPtr);
r:A.Regs;
BEGIN
r.a[0] := SYSTEM.VAL(LONGINT, port);
A.LibCall(execBase,-384,r)
END WaitPort;
PROCEDURE GetMsg*(port: MsgPortPtr): MessagePtr;
r:A.Regs;
BEGIN
r.a[0] := SYSTEM.VAL(LONGINT, port);
A.LibCall(execBase,-372,r);
RETURN SYSTEM.VAL(MessagePtr, r.d[0])
END GetMsg;
PROCEDURE ReplyMsg*(msg: MessagePtr);
r:A.Regs;
BEGIN
r.a[1] := SYSTEM.VAL(LONGINT, msg);
A.LibCall(execBase,-378,r)
END ReplyMsg;
PROCEDURE CloseDevice*(ioRequest: MessagePtr);
VAR r:A.Regs;
BEGIN
r.a[1]:=ioRequest;
A.LibCall(execBase,-450,r)
END CloseDevice;
PROCEDURE DoIO*(ioRequest: MessagePtr): SHORTINT;
VAR r:A.Regs;
BEGIN
r.a[1]:=ioRequest;
A.LibCall(execBase,-456,r);
RETURN SHORT(SHORT(r.d[0]))
END DoIO;
PROCEDURE SendIO*(ioRequest: MessagePtr);
VAR r:A.Regs;
BEGIN
r.a[1]:=ioRequest;
A.LibCall(execBase,-462,r)
END SendIO;
PROCEDURE CheckIO*(ioRequest: MessagePtr): BOOLEAN;
VAR r:A.Regs;
BEGIN
r.a[1]:=ioRequest;
A.LibCall(execBase,-468,r);
RETURN r.d[0]#0
END CheckIO;
PROCEDURE WaitIO*(ioRequest: MessagePtr): SHORTINT;
VAR r:A.Regs;
BEGIN
r.a[1]:=ioRequest;
A.LibCall(execBase,-474,r);
RETURN SHORT(SHORT(r.d[0]))
END WaitIO;
PROCEDURE AbortIO*(ioRequest: MessagePtr): LONGINT;
VAR r:A.Regs;
BEGIN
r.a[1]:=ioRequest;
A.LibCall(execBase,-480,r);
RETURN r.d[0]
END AbortIO;
PROCEDURE CreateMsgPort*(): MsgPortPtr;
VAR r:A.Regs;
BEGIN
A.LibCall(execBase,-666,r);
RETURN r.d[0]
END CreateMsgPort;
PROCEDURE DeleteMsgPort*(port: MsgPortPtr);
VAR r:A.Regs;
BEGIN
r.a[0]:=port;
A.LibCall(execBase,-672,r)
END DeleteMsgPort;
PROCEDURE CreateIORequest*(port: MsgPortPtr; size: LONGINT): MessagePtr;
VAR r:A.Regs;
BEGIN
r.a[0]:=port;
r.d[0]:=size;
A.LibCall(execBase,-654,r);
RETURN r.d[0]
END CreateIORequest;
PROCEDURE DeleteIORequest*(iorequest: MessagePtr);
VAR r:A.Regs;
BEGIN
r.a[0]:=iorequest;
A.LibCall(execBase,-660,r)
END DeleteIORequest;
(* Memory Pool Procedures *)
PROCEDURE CreatePool*(reqs: SET; puddleSize, threshSize: LONGINT):MemPoolPtr;
VAR r:A.Regs;
BEGIN
r.d[0]:=SYSTEM.VAL(LONGINT,reqs);
r.d[1]:=puddleSize;
r.d[2]:=threshSize;
A.LibCall(execBase,-696,r);
RETURN r.d[0]
END CreatePool;
PROCEDURE DeletePool*(pool: MemPoolPtr);
VAR r:A.Regs;
BEGIN
r.a[0]:=pool;
A.LibCall(execBase,-702,r)
END DeletePool;
PROCEDURE AllocPooled*(pool: MemPoolPtr; size: LONGINT):LONGINT;
VAR r:A.Regs;
BEGIN
r.a[0]:=pool;
r.d[0]:=size;
A.LibCall(execBase,-708,r);
RETURN r.d[0]
END AllocPooled;
PROCEDURE FreePooled*(pool: MemPoolPtr; adr, size: LONGINT);
VAR r:A.Regs;
BEGIN
r.a[0]:=pool;
r.a[1]:=adr;
r.d[0]:=size;
A.LibCall(execBase,-714,r)
END FreePooled;
PROCEDURE Init;
LibraryPtr=POINTER TO Library;
lib:LibraryPtr;
BEGIN
execBase:=A.ExecBase();
lib:=SYSTEM.VAL(LibraryPtr,execBase);
execVersion:=lib.version
END Init;
BEGIN
Init
END AmigaExec.