annotate level2/modules/kernel/fnproc.asm @ 2639:283433fa565c

Added notes to atari.d
author Boisy Pitre <boisy.pitre@nuance.com>
date Tue, 28 Feb 2012 09:26:09 -0600
parents 530759e9f289
children ead54d2c06d4
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$NProc
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: Start the next process in the active queue
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: None
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: Control does not return to the caller
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
9 *
1387
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
10 FNProc
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
11 IFGT Level-1
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
12 ldx <D.SysPrc get system process descriptor
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
13 stx <D.Proc save it as current
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
14 lds <D.SysStk get system stack pointer
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
15 andcc #^IntMasks re-enable IRQ's (to allow pending one through)
1387
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
16 ELSE
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
17 clra
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
18 clrb
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
19 std <D.Proc
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
20 ENDC
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
21 fcb $8C skip the next 2 bytes
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
22
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
23 L0D91 cwai #^IntMasks re-enable IRQ's and wait for one
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
24 L0D93 orcc #IntMasks Shut off interrupts again
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
25 lda #Suspend get suspend suspend state flag
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
26 ldx #D.AProcQ-P$Queue For start of loop, setup to point to current process
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
27
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
28 * Loop to find next active process that is not Suspended
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
29 L0D9A leay ,x Point y to previous link (process dsc. ptr)
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
30 ldx P$Queue,y Get process dsc. ptr for next active process
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
31 beq L0D91 None, allow any pending IRQ thru & try again
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
32 bita P$State,x There is one, is it Suspended?
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
33 bne L0D9A Yes, skip it & try next one
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
34
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
35 * Found a process in line ready to be started
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
36 ldd P$Queue,x Get next process dsc. ptr in line after found one
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
37 std P$Queue,y Save the next one in line in previous' next ptr
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
38 stx <D.Proc Make new process dsc. the current one
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
39 lbsr L0C58 Go check or make a task # for the found process
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
40 bcs L0D83 Couldn't get one, go to next process in line
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
41 lda <D.TSlice Reload # ticks this process can run
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
42 sta <D.Slice Save as new tick counter for process
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
43 ldu P$SP,x get the process stack pointer
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
44 lda P$State,x get it's state
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
45 lbmi L0E29 If in System State, switch to system task (0)
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
46 L0DB9 bita #Condem Was it condemned by a deadly signal?
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
47 bne L0DFD Yes, go exit with Error=the signal code #
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
48 lbsr TstImg do a F$SetTsk if the ImgChg flag is set
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
49 L0DBD ldb <P$Signal,x any signals?
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
50 beq L0DF7 no, go on
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
51 decb is it a wake up signal?
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
52 beq L0DEF yes, go wake it up
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
53 leas -R$Size,s make a register buffer on stack
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
54 leau ,s point to it
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
55 lbsr L02CB copy the stack from process to our copy of it
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
56 lda <P$Signal,x get last signal
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
57 sta R$B,u save it to process' B
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
58
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
59 ldd <P$SigVec,x any intercept trap?
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
60 beq L0DFD no, go force the process to F$Exit
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
61 std R$PC,u save vector to it's PC
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
62 ldd <P$SigDat,x get pointer to intercept data area
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
63 std R$U,u save it to it's U
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
64 ldd P$SP,x get it's stack pointer
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
65 subd #R$Size take off register stack
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
66 std P$SP,x save updated SP
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
67 lbsr L02DA Copy modified stack back overtop process' stack
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
68 leas R$Size,s purge temporary stack
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
69 L0DEF clr <P$Signal,x clear the signal
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
70
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
71 * No signals go here
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
72 L0DF7 equ *
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
73 IFNE H6309
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
74 oim #$01,<D.Quick
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
75 ELSE
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
76 ldb <D.Quick
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
77 orb #$01
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
78 stb <D.Quick
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
79 ENDC
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
80 BackTo1 equ *
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
81 L0DF2 ldu <D.UsrSvc Get current User's system call service routine ptr
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
82 stu <D.XSWI2 Save as SWI2 service routine ptr
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
83 ldu <D.UsrIRQ Get IRQ entry point for user state
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
84 stu <D.XIRQ Save as IRQ service routine ptr
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
85
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
86 ldb P$Task,x get task number
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
87 lslb 2 bytes per entry in D.TskIpt
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
88 ldy P$SP,x get stack pointer
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
89 lbsr L0E8D re-map the DAT image, if necessary
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
90
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
91 ldb <D.Quick get quick return flag
2615
530759e9f289 Added ccbkrn from Brett Gordon (level 2 only for now)
Boisy Pitre <boisy.pitre@nuance.com>
parents: 1387
diff changeset
92 lbra L0E4C Go switch GIME over to new process & run
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
93
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
94 * Process a signal (process had no signal trap)
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
95 L0DFD equ *
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
96 IFNE H6309
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
97 oim #SysState,P$State,x Put process into system state
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
98 ELSE
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
99 ldb P$State,x
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
100 orb #SysState
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
101 stb P$State,x
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
102 ENDC
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
103 leas >P$Stack,x Point SP to process' stack
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
104 andcc #^IntMasks Turn interrupts on
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
105 ldb <P$Signal,x Get signal that process received
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
106 clr <P$Signal,x Clear out the one in process dsc.
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
107 os9 F$Exit Exit with signal # being error code
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
108
1239
90bad6d8388c Major changes to bring kernel closer to L2 port
boisy
parents: 1145
diff changeset
109 S.SvcIRQ jmp [>D.Poll] Call IOMAN for IRQ polling