annotate level2/modules/kernel/fmem.asm @ 3195:6eb2edad80d8

L2: Introduce symbol KrnBlk to define kernel block number This is the block number that the kernel is loaded into. This is platform-specific, a function of the behaviour of the platform MMU/DAT. CRCs are unaffected by this change.
author Neal Crook <foofoobedoo@gmail.com>
date Thu, 01 Jun 2017 22:13:49 +0100
parents 039ddb7c8ad7
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
1 **************************************************
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
2 * System Call: F$Mem
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
3 *
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
4 * Function: Resize data memory area
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
5 *
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
6 * Input: D = Desired memory area (in bytes)
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
7 *
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
8 * Output: Y = Address of new memory area upper bound
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
9 * D = New memory area size in bytes
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
10 *
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
11 * Error: CC = C bit set; B = error code
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
12 *
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
13 FMem ldx <D.Proc get current process pointer
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
14 ldd R$D,u get requested memory size
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
15 beq L0638 he wants current size, return it
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
16 addd #$00FF round up to nearest page
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
17 bcc L05EE no overflow, skip ahead
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
18 ldb #E$MemFul get mem full error
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
19 rts return
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
20
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
21 L05EE cmpa P$PagCnt,x match current page count?
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
22 beq L0638 yes, return it
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
23 pshs a save page count
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
24 bhs L0602 he's requesting more, skip ahead
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
25 deca subtract a page
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
26 ldb #($100-R$Size) get size of default stack - R$Size
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
27 cmpd P$SP,x shrinking it into stack?
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
28 bhs L0602 no, skip ahead
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
29 ldb #E$DelSP get error code (223)
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
30 bra L0627 return error
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
31 L0602 lda P$PagCnt,x get page count
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
32 adda #$1F round it up
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
33 lsra divide by 32 to get block count
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
34 lsra
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
35 lsra
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
36 lsra
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
37 lsra
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
38 ldb ,s
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
39 addb #$1F
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
40 bcc L0615 still have room, skip ahead
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
41 ldb #E$MemFul
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
42 bra L0627
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
43 L0615 lsrb divide by 32 to get block count
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
44 lsrb
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
45 lsrb
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
46 lsrb
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
47 lsrb
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
48 IFNE H6309
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
49 subr a,b same count?
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
50 ELSE
1239
90bad6d8388c Major changes to bring kernel closer to L2 port
boisy
parents: 1145
diff changeset
51 pshs a
90bad6d8388c Major changes to bring kernel closer to L2 port
boisy
parents: 1145
diff changeset
52 subb ,s+
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
53 ENDC
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
54 beq L0634 yes, save it
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
55 bcs L062C overflow, delete the ram we just got
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
56 os9 F$AllImg allocate the image in DAT
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
57 bcc L0634 no error, skip ahead
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
58 L0627 leas 1,s purge stack
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
59 L0629 orcc #Carry set carry for error
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
60 rts return
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
61
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
62 L062C equ *
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
63 IFNE H6309
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
64 addr b,a
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
65 ELSE
1239
90bad6d8388c Major changes to bring kernel closer to L2 port
boisy
parents: 1145
diff changeset
66 pshs b
90bad6d8388c Major changes to bring kernel closer to L2 port
boisy
parents: 1145
diff changeset
67 adda ,s+
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
68 ENDC
3123
039ddb7c8ad7 l2 kernel: Remove tabs and trailing whitespace, align comments
Neal Crook <foofoobedoo@gmail.com>
parents: 1239
diff changeset
69 negb
039ddb7c8ad7 l2 kernel: Remove tabs and trailing whitespace, align comments
Neal Crook <foofoobedoo@gmail.com>
parents: 1239
diff changeset
70 os9 F$DelImg
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
71 L0634 puls a restore requested page count
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
72 sta P$PagCnt,x save it into process descriptor
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
73 L0638 lda P$PagCnt,x get page count
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
74 clrb clear LSB
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
75 std R$D,u save mem byte count to caller
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
76 std R$Y,u save memory upper limit to caller
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
77 rts return