1345
|
1 **************************************************
|
|
2 * System Call: F$CpyMem
|
|
3 *
|
|
4 * Function: Copy external memory
|
|
5 *
|
|
6 * Input: D = Starting memory block number
|
|
7 * X = Offset in block to begin copy
|
|
8 * Y = Byte count
|
|
9 * U = Caller's destination buffer
|
|
10 *
|
|
11 * Output: None
|
|
12 *
|
|
13 * Error: CC = C bit set; B = error code
|
|
14 *
|
1145
|
15 IFNE H6309
|
1345
|
16 * F$CpyMem for NitrOS-9 Level Two
|
|
17 * Notes:
|
|
18 * We currently check to see if the end of the buffer we are
|
|
19 * copying to will overflow past $FFFF, and exit if it does.
|
|
20 * Should this be changed to check if it overflows past the
|
|
21 * data area of a process, or at least into Vector page RAM
|
|
22 * and I/O ($FE00-$FFFF)???
|
|
23 *
|
1145
|
24 FCpyMem ldd R$Y,u get byte count
|
|
25 beq L0A01 nothing there so nothing to move, return
|
|
26 addd R$U,u add it caller's buffer start ptr.
|
|
27 cmpa #$FE Is it going to overwrite Vector or I/O pages?
|
|
28 bhs L0A01 Yes, exit without error
|
|
29 leas -$10,s make a buffer for DAT image
|
|
30 leay ,s point to it
|
|
31 pshs y,u Preserve stack buffer ptr & register stack pointer
|
|
32 ldx <D.Proc Get caller's task #
|
|
33 ldf P$Task,x get task # of caller
|
|
34 leay P$DATImg,x Point to DAT image in callers's process dsc.
|
|
35 ldx R$D,u get caller's DAT image pointer
|
|
36 lde #$08 counter (for double byte moves)
|
|
37 ldu ,s get temp. stack buffer pointer
|
|
38
|
|
39 * This loop copies the DAT image from the caller's process descriptor into
|
|
40 * a temporary buffer on the stack
|
|
41 L09C7 equ *
|
|
42 clrd Clear offset to 0
|
|
43 bsr L0B02 Short cut OS9 F$LDDDXY
|
|
44 std ,u++ save it to buffer
|
|
45 leax 2,x Bump ptr
|
|
46 dece Decrement loop counter
|
|
47 bne L09C7 Keep doing until 16 bytes is done
|
|
48
|
|
49 ldu 2,s Get back register stack pointer
|
|
50 lbsr L0CA6 Short cut OS9 F$ResTsk
|
|
51 bcs L09FB If error, deallocate our stack & exit with error
|
|
52 tfr b,e New temp task # into E
|
|
53 lslb Multiply by 2 for 2 byte entries
|
|
54 ldx <D.TskIPt Get ptr to task image table
|
|
55 * Make new temporary task use the memory blocks from the requested DAT image
|
|
56 * from the caller, to help do a 1 shot F$Move command, because in general
|
|
57 * the temporary DAT image is not associated with a task.
|
|
58 ldu ,s Get pointer to DAT image we just copied
|
|
59 stu b,x Point new task image table to our DAT image copy
|
|
60 ldu 2,s Get back data area pointer
|
|
61 tfr w,d Move temp & caller's task #'s into proper regs.
|
|
62 pshs a Save new task #
|
|
63 bsr L0B25 F$Move the memory into the caller's requested area
|
|
64 * BAD Bug! Well, maybe not. F$Move NEVER returns an error code
|
|
65 * but if it did, we'd skip the $RelTsk, and have an orphan task
|
|
66 * left over.
|
|
67 * bcs L09FB If error, purge stack & return with error code
|
|
68 puls b Get back new task #
|
|
69 lbsr L0CC3 Short cut OS9 F$RelTsk
|
|
70 L09FB leas <$14,s Purge our stack buffer & return
|
|
71 rts
|
|
72
|
|
73 L0A01 clrb No error & exit
|
|
74 rts
|
|
75
|
|
76
|
|
77 ELSE
|
|
78
|
1345
|
79 * F$CpyMem for OS-9 Level Two
|
1145
|
80 FCpyMem ldd R$Y,u byte count
|
|
81 beq L0A01 ..skip if none
|
|
82 addd R$U,u plus dest buff
|
|
83 bcs L0A01
|
|
84 leas -$10,s
|
|
85 leay ,s
|
|
86 pshs a,b,y save buff end,img ptr
|
|
87 ldx <D.Proc
|
|
88 ldb P$Task,X
|
|
89 pshs b save caller task#
|
|
90 leay P$DATImg,x
|
|
91 ldx R$D,u X=caller DAT img ptr
|
|
92 ldb #8
|
|
93 pshs b,u
|
|
94 ldu P$Task,s U=tempdat ptr
|
|
95
|
|
96 L09C7 clra D=0000
|
|
97 clrb
|
|
98 os9 F$LDDDXY move user DAT image
|
|
99 std ,u++ to sys tempDAT img
|
|
100 leax 2,x
|
|
101 dec ,s
|
|
102 bne L09C7 ..loop
|
|
103
|
|
104 puls b,u
|
|
105 ldx R$X,u X=offset
|
|
106 ldu R$U,u U=dest buffer
|
|
107 ldy 3,s Y=tmpDAT
|
|
108
|
|
109 puls b
|
|
110 bra L09E7
|
|
111
|
|
112 N09D6 leax $E000,x
|
|
113 leay 2,y
|
|
114
|
|
115 *------------------------------------------------*
|
|
116 * Copy Loop:
|
|
117
|
|
118 L09E7 cmpx #$2000
|
|
119 bcc N09D6
|
|
120
|
|
121 L09EC os9 F$LDAXY get byte
|
|
122 leax 1,x
|
|
123 exg x,u
|
|
124
|
|
125 os9 F$STABX store byte
|
|
126 leax 1,x plus one
|
|
127 cmpx ,s
|
|
128 exg x,u
|
|
129 bcs L09E7
|
|
130 leas $14,s
|
|
131
|
|
132 L0A01 clrb ok
|
|
133 rts end.
|
|
134
|
|
135 ENDC
|
|
136
|