1345
|
1 **************************************************
|
|
2 * System Call: F$UnLoad
|
|
3 *
|
|
4 * Function: Unlink a module by name
|
|
5 *
|
|
6 * Input: A = Module type
|
|
7 * X = Pointer to module name
|
|
8 *
|
|
9 * Output: None
|
|
10 *
|
|
11 * Error: CC = C bit set; B = error code
|
|
12 *
|
1145
|
13 FUnLoad pshs u preserve register stack pointer
|
|
14 lda R$A,u get module type
|
|
15 ldx <D.Proc get current process pointer
|
|
16 leay P$DATImg,x point to DAT image
|
|
17 ldx R$X,u get pointer to name
|
|
18 os9 F$FModul find it in module directory
|
|
19 puls y restore register stack pointer
|
|
20 bcs L0A4F couldn't find it, return error
|
|
21 stx R$X,y save update name pointer
|
|
22 IFNE H6309
|
|
23 ldw MD$Link,u get link count
|
|
24 beq L0A21 already 0 check if it's a I/O module
|
|
25 decw subtract 1
|
|
26 stw MD$Link,u save it back
|
|
27 ELSE
|
|
28 ldx MD$Link,u get module link count
|
|
29 beq L0A21 branch if zero
|
|
30 leax -1,x else decrement
|
|
31 stx MD$Link,u
|
|
32 ENDC
|
|
33 bne L0A4E not zero, don't remove from memory, return
|
|
34
|
|
35 * Link count is zero, check if module can be removed from memory
|
|
36 L0A21 cmpa #FlMgr is it a I/O module?
|
|
37 blo L0A4B no, remove module from memory
|
|
38
|
|
39 * Special handling for I/O module deletion
|
|
40 clra
|
|
41 ldx [MD$MPDAT,u] get 1st 2 blocks in DAT image of module
|
|
42 ldy <D.SysDAT get pointer to system DAT image
|
|
43 L0A2B adda #2
|
|
44 cmpa #DAT.ImSz done entire DAT?
|
|
45 bcc L0A4B yes, delete the module from memory
|
|
46 cmpx a,y find block?
|
|
47 bne L0A2B no, keep looking
|
|
48 lsla multiply by 16 to calculate the offset
|
|
49 lsla
|
|
50 lsla
|
|
51 lsla
|
|
52 clrb
|
|
53 addd MD$MPtr,u add in the pointer
|
|
54 tfr d,x copy it to X
|
|
55 os9 F$IODel delete the device from memory
|
|
56 bcc L0A4B no error, skip ahead
|
|
57
|
|
58 IFNE H6309
|
|
59 ldw MD$Link,u put link count back
|
|
60 incw
|
|
61 stw MD$Link,u
|
|
62 ELSE
|
|
63 ldx MD$Link,u put link count back
|
|
64 leax 1,x
|
|
65 stx MD$Link,u
|
|
66 ENDC
|
|
67 rts Return with error
|
|
68
|
|
69 * Delete module from memory
|
|
70 L0A4B lbsr DelMod Delete module from memory
|
|
71 L0A4E clrb clear errors
|
|
72 L0A4F rts return
|