Inside - THE SYSTEM

From NitrOS-9
Jump to: navigation, search

Section 1

Level-2 PROCESS DESCRIPTOR VARIABLES

 00     P$ID       Process   ID
 01     P$PID      Parent's  ID
 02     P$SID      Sibling's ID
 03     P$CID      Child's   ID
                     The family proc id numbers.
 04-05  P$SP       Stack Pointer storage
                     SP position within Process map
 06     P$Task     Task Number
                     Virtual DAT task number
 07     P$PagCnt   Data Memory Page Count
 08-09  P$USer     User Index
 0A     P$Prior    Priority
 0B     P$Age      Age
                     The age always begins at Priority.
 0C     P$State    Status
                     System Image Changed Dead, etc.
 0D-0E  P$Queue    Queue Link (next process desc ptr)
                     For active, waiting, sleeping procs.
 0F     P$IOQP     Previous I/O Queue Link (Proc ID)
 10     P$IOQN     Next I/O Queue Link (Proc ID)
                     Path or driver queues.
 11-12  P$PModul   Primary Module pointer
                     Offset Within proc map to program.
 13-14  P$SWI      SWI  Entry Point
 15-16  P$SWI2     SWI2 Entry Point
 17-18  P$SWI3     SWI3 Entry Point
                     May be changed to point to proc map.
 19     P$Signal   Signal Code
 1A-1B  P$SigVec   Signal Intercept Vector
 1C-1D  P$SigDat   Signal Intercept Data Address (U)
                     Signal storage and user-defined vector.
 1E     P$DeadLk   Dominant proc ID for locked I/O
 20-2E  P$DIO      Default I/O ptrs (chd, chx)
                     Drive table and LSN entries.
 3O-3F  P$Path     I/O Path Table (real path numbers)
                     User path numbers 0-F index here to the
                     actual path descriptor number involved.
 40-7F  P$DATImg   DAT Image (only 16 used in CoCo - 3)
                     The block map of this 64K process space.
 80-9E  P$Links    Block Link counts (for user map) (8 used)
                     To keep track of map-internal links.
 A0-AB             Network variables?
 AC                Path number (0, 1, 2) for selected window
         rmb $200 - . Local stack
 P$Stack equ 512 Top of Stack
 P$Size  equ 512 Size of Process Descriptor

There are three main differences between a Level-1 and Level-2 process descriptor. The Level-2 additions are:

  • DAT Image - so OS-9 knows what to map in for the process.
  • Link Cnts - so an unlink won't unmap blocks with other still-linked-into-this-map modules.
  • Stack area - used while in the system state.

The link counts apply to that process map only, and are counts of block links, not individual modules. Say you had a merged module file loaded with Runb, Syscall and Inkey all together taking up two blocks. The first logical block number of the whole group will have a link count of one.

Then perhaps your program calls Inkey. Inkey is found in your map already, and the first block number link count is incremented in the process descriptor. The module directory link count is incremented also.

Now Inkey finishes and is unlinked. The link count is decremented in the module directory and could easily now be zero. But you don't want Runb and Syscall to go away, too! And they won't because the process map block link now only goes down to one again, and so both blocks mapped will stay mapped.

The stack area is needed when an interrupt (software or hardware) occurs. The initial register save will be within the process' stack area. Then OS-9 flips over to the system map, where, in case this process' time is up and it's whole state must be saved, OS9 begins using the process descriptor stack area instead.

In a way, the process descriptor stack is an extension of the process data area into the system map.

Under Level-1, of course, there was no need for this, as everyone's stack was available at all times.

Level-2 Direct Page Variable Map $00XX

  • Names are standard Level-2. Defs with no name are new CoCo-3 variables.
20-21. D. Tasks Task Pro C User Table
Points to 32 byte task if map.
22-23 D. TmpDAT Temporary DAT Image stack
Used to point to images used in moves.
24-25 D . Init INIT Module ptr
Points to the Init module.
26-27 D. Poll Interrupt Polling Routine
Vector to IOMan subo to find IRQ sources .
28 D. Time System Time Variables:
28 D. Year Year
29 D. Month Month
2A D. Day Day
2B D. Hollr HOU
2C D. Min Minute
2D D. Se C Seconds
________________
2E
2F
30
32
36-37 38-39
40ー41
44一45
48-49
4A-4B
4C-4D
4Eー4F
| 5س50
52-53
54ー55
56-57
58-59
5A-5B
6B-6C
71-7C
80-81
82-83
88-89
8A
90
91
92
93-9F
AO A1-A2
D. Tick
D. Slice
D. TSlice
D - MOt On
D. BlkMap
D. ModDir
O - PCDBT
D. SysPrc
D. SysDAT
D - SysMem
D. Proc
D. AProcQ
D.WProcO
D - S ProcQ
D. ModEnd
D - ModDAT
D - DevTbl
D. POl'Tbl
D. PthDBT
D. DMAReq

Tick countdown for slice
60 Hz IRQ count . ( 60 ticks = 1 second) Current slice remaining
Ticks left for current process normal run. Ticks per Slice constant
Set to 6 = 1/10 second per process slice Drive Motor time out
Boot start address Boot length
New variables for use by os9gen & cobbler.
Memory Block Map
Points to 64 byte physical block flag array. Module Directory
Points to the 8 byte dir entries start. Process Descriptor Block Table
Points to 256 byte array of msb addresses. System Process Descriptor
Points to proc desc used while in Sys State. System DAT Image
Points to the image within D. SysPro desc. System Mem Map
Points to 256 byte page table for systm map. Current Process Des C
Points to the proc desc in use now. Active Process Queue
First proc desc link of procs ready to run. Waiting Process Queue
First proc desc link of procs that FSWait" d. Sleeping Process Queue
First proc desc link of procs sleeping. Module Directory end
Module Directory DAT image end
"Boot Failed" REL vector
Vector to display of this message. CoCo reset code
55 NOP NOP B7 EFF DE 7E EF0 0E I/O Device Table
Points to array of 9-byte device entries. I/O Polling Table
Points to array of 9-byte IRQ poll entries . Path Descriptor Block Table ptr
Points to base 256-byte path descs table. DMA Request flag (MPI slot use)
Set= MPI slot has been changed. CC3Disk flag.
GIME register copies : Init Reg SFF91 shadow for tasks IRQEN ŞFF92 shadow IRQ enables other GIME shadows
Speed flag (1=2Mhz)
Task DAT Image Ptrs Table ptr
Pointer to 32 image pointers for task #'s.
2-1-3
________________
A3 A4 A5-A6
A7-A8
A9-AA AB-AC AD-AE
AE
B0-B1.
B2-B3
CO-C1 C2-C3 C4-C5 C6-C7 C8-C9 CA-CB CC-CD CE-CF DO
E0一E卫 E2一B3 E4一E5 E6一E7 E8-E9 EA-EB EC-ED
F2-F3 F4ーF5 F6-F7 F8-F9 FA-FB FC-FD
D. SysSvc D. SysDis D. SysIRQ D. UsrSvc D. UsrDis D. Us3rIRQ D. Sys Stk D . Svo:TRO D. SysTsk
D. Clock D. XSW3 D. XSWI2 D. XEIRQ D. XIIIRQ D . XSW). D - XINMI
D. SWI3 D. SWI2 D . FIR.Q D. IRQ
D - SW DNMI

0=128K, 1=512K temp flag FF91 Task Reg Bit (which system state task) Global CC3IO memory
Pointer to $1 000 : global mem. Grfdrv SP storage
Pointer to end of global mem. sysmap 1 stack. Grforv ->kernal return vector Kernal ->grforv second sysmap Clock SvcIRO vector for VIRO GIME IRQ bits status
Set bit as unpolled interrupt as yet. VIRQ table
Pointer to the Virtual Interrupt table. CC3IO Keybd IRQ vector
Vector to keyboard scan sub . . . used by Clock.
System Service Routine entry System Service Dispatch Table Sys State IRQ Routine entry User Service Routine entry User Service Dispatch Table User State IRQ Routine entry System stack In-System IRQ service System Task number
Secondary Vectors :
Primary Interrupt Vectors :
(most point to their D.X form above)

OTHER SYSTEM RAM USAGE

(from above pointers- for info only)

0.00-01E D. Tasks Task table
O120-015F 00A1-A2 Virtual dat tasks ptr
O2 00-023F D. BlkMap Block usage map
(S80 enotram, SOl=in use + S02-module)
0300-03FF D. SysDis Sys call dispatch table
O 400-0 AFF D. UsrDis. User call dispatch table
O500-05FF D. PricDBT Proc Desc ptrs table
O 600-07FF D. SysPro System proc desc
0800–08FF D. SysStk (0900) system stack space
0900-09FF D. SysMem System page ram map (S01=in use)
OAOO-OFFF D. ModDir Module DATImages
1000-1FFF Global cc3io mem, alarm & system use

LOW MEMORY DUMP (00000-00FFF)

{Term|04}/DD:dmem 0 0 1000 ! dump

Address   0 1  2 3  4 5  6 7  8 9  A B  C D  E F  0 2 4 6 8 A C E
-------- ---- ---- ---- ---- ---- ---- ---- ----  ----------------
00000000 0000 0000 0000 0000 0000 0000 0000 0000  ................  System Direct Page
00000010 0000 0000 0000 0000 0000 0000 0000 0000  ................  Variables
00000020 0100 0000 A85B A515 7505 1300 062D 2B01  ....([%.u....-+.
00000030 0201 0000 0000 9200 5AF0 0000 0006 0100  ........Zp......
00000040 0200 0240 0A00 1000 0500 0600 0640 0900  ...@.........@..
00000050 7F00 8300 8500 0000 0B88 0EC0 0000 7EED  ...........@..~m
00000060 A600 0000 0000 0000 0000 007E ED17 0000  &..........~m...
00000070 7455 7FFF DF39 3939 3939 3900 1300 0000  tU.._999999.....
00000080 8E00 8FFB 0000 0000 8D00 0000 0000 0000  ...{............
00000090 00A0 0000 0000 0000 0000 0000 0000 0000  . ..............
000000A0 0001 2000 0010 0020 0001 60FE 5ECD 1700  .. .... ..`~^M..
000000B0 90E2 F1A6 0000 CEBC 0000 0000 0000 0000  .bq&..N<........
000000C0 F2ED 0300 FDFC F225 0400 FD05 0900 CD17  rm..}|r%..}...M.
000000D0 0000 0000 0000 0000 0000 0000 0000 0000  ................
000000E0 FCA0 F217 F2ED 006B FDFC F21A 006B 0055  | r.rm.k}|r..k.U
000000F0 F309 F037 F037 F037 CD00 F037 F037 0000  s.p7p7p7M.p7p7..

Address   0 1  2 3  4 5  6 7  8 9  A B  C D  E F  0 2 4 6 8 A C E
-------- ---- ---- ---- ---- ---- ---- ---- ----  ----------------
00000100 0101 0203 0000 0000 0000 0000 0000 0000  ................  Task Number Use Table
00000110 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000120 0640 0000 8340 7F40 7F40 0000 0000 0000  .@...@.@.@......  Virtual DAT: pointers
00000130 0000 0000 0000 0000 0000 0000 0000 0000  ................  to task # DAT images
00000140 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000150 0000 0000 0000 0000 0000 0000 0000 0000  ................  The ones here are:
00000160 3402 9691 84BF 9791 B7FF DE35 020F A41F  4....?..7.^5..$.   task 0 (0640) = system
00000170 141F 8A39 0000 0000 0000 0000 0000 0000  ...9............   task 1 (0000) = ???
00000180 0000 0000 0000 0000 0000 0000 0000 0000  ................   task 2 (8340) = ??
00000190 0000 0000 0000 0000 0000 0000 0000 0000  ................   task 3 (7F40) = ??
000001A0 0000 0000 0000 0000 0000 0000 0000 0000  ................   task 4 (7F40) = ??
000001B0 0000 0000 0000 0000 0000 0000 0000 0000  ................
000001C0 0000 0000 0000 0000 0000 0000 0000 0000  ................
000001D0 0000 0000 0000 0000 0000 0000 0000 0000  ................
000001E0 0000 0000 0000 0000 0000 0000 0000 0000  ................
000001F0 0000 0000 0000 0000 0000 0000 0000 0000  ................

Address   0 1  2 3  4 5  6 7  8 9  A B  C D  E F  0 2 4 6 8 A C E
-------- ---- ---- ---- ---- ---- ---- ---- ----  ----------------
00000200 0101 0101 0101 0101 0103 0103 0000 0000  ................  Block Map (64 bytes)
00000210 0000 0000 0000 0000 0000 0000 0000 0000  ................    80 = not RAM
00000220 0000 0000 0000 0000 0000 0000 0000 0000  ................    02 = contains module
00000230 0000 0000 0000 0000 0000 0000 0000 0000  ................    01 = RAM in use
00000240 0000 0000 0000 0000 0000 0000 0000 0000  ................    03 = module, RAM in use
00000250 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000260 0000 0000 0000 0000 0000 0000 0000 0000  ................  "MFREE" would check this map
00000270 0000 0000 0000 0000 0000 0000 0000 0000  ................  using F$GBlkMp call.
00000280 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000290 0000 0000 0000 0000 0000 0000 0000 0000  ................
000002A0 0000 0000 0000 0000 0000 0000 0000 0000  ................
000002B0 0000 0000 0000 0000 0000 0000 0000 0000  ................
000002C0 0000 0000 0000 0000 0000 0000 0000 0000  ................
000002D0 0000 0000 0000 0000 0000 0000 0000 0000  ................
000002E0 0000 0000 0000 0000 0000 0000 0000 0000  ................
000002F0 0000 0000 0000 0000 0000 0000 0000 0000  ................

Address   0 1  2 3  4 5  6 7  8 9  A B  C D  E F  0 2 4 6 8 A C E
-------- ---- ---- ---- ---- ---- ---- ---- ----  ----------------
00000300 F362 A5BE 9345 943E 952E 95A7 973D 97D8  sb%>.E.>...'.=.X  System dispatch table (SWI2)
00000310 9838 98ED 98FB 0000 9A01 99E5 9A90 A78C  .8.m.{.....e..'.
00000320 F6FC F797 9BAE 9AE3 9B57 CE2C CE40 F606  v|w....c.WN,N@v.
00000330 9C09 9C22 9C3D 9A0D 9C5B 9C63 CDF5 0000  ...".=...[.cMu..
00000340 0000 A556 A537 9EDA 0000 0000 0000 CDB0  ..%V%7.Z......M0
00000350 F7F4 F848 A495 A7D4 FCDD FD5C F421 9CAF  wtxH$.'T|]}\t!./
00000360 9CC9 9D4C F337 9FC2 F355 F8A5 F7F4 9D7C  .I.Ls7.BsUx%wt.|
00000370 FACC 99A0 F941 9D9E FA05 F9F2 F9AC FC31  zL. yA..z.yry,|1
00000380 FC41 FC52 FC75 FC93 FA24 0000 FA3C 0000  |A|R|u|.z$..z<..
00000390 FA82 FBF3 FC12 94D8 952A F35A F648 9DCC  z.{s|..X.*sZvH.L
000003A0 9E07 9A68 9E44 99CE 0000 930A 0000 F8E9  ...h.D.N......xi
000003B0 0000 0000 0000 0000 0000 0000 0000 0000  ................
000003C0 0000 0000 0000 0000 0000 0000 0000 0000  ................
000003D0 0000 0000 0000 0000 0000 0000 0000 0000  ................
000003E0 0000 0000 0000 0000 0000 0000 0000 0000  ................
000003F0 0000 0000 0000 0000 0000 0000 0000 A02F  .............. /  (T$call vector)

Address   0 1  2 3  4 5  6 7  8 9  A B  C D  E F  0 2 4 6 8 A C E
-------- ---- ---- ---- ---- ---- ---- ---- ----  ----------------
00000400 F362 A591 9345 943E 952E 95A7 973D 97D8  sb%..E.>...'.=.X  User dispatch table (SWI2)
00000410 9838 98ED 98FB 0000 9A01 99E5 9A90 A78C  .8.m.{.....e..'.
00000420 F6FC F78C 9BA1 9AD6 9B4A CE2C CE40 F606  v|w..!.V.JN,N@v.
00000430 9C09 9C22 9C3D 9A0D 9C5B 9C63 CDF5 0000  ...".=...[.cMu..  Notice that this is a sub-set
00000440 0000 A556 A537 9EDA 0000 0000 0000 CDB0  ..%V%7.Z......M0  of the system dispatch table:
00000450 0000 0000 0000 0000 0000 0000 0000 0000  ................  many of the calls are not
00000460 0000 0000 0000 0000 0000 0000 0000 0000  ................  available to the user.
00000470 0000 99A0 0000 0000 0000 0000 0000 0000  ... ............
00000480 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000490 0000 0000 0000 0000 0000 0000 0000 9DCC  ...............L
000004A0 9E07 9A68 0000 0000 0000 930A 0000 0000  ...h............
000004B0 0000 0000 0000 0000 0000 0000 0000 0000  ................
000004C0 0000 0000 0000 0000 0000 0000 0000 0000  ................
000004D0 0000 0000 0000 0000 0000 0000 0000 0000  ................
000004E0 0000 0000 0000 0000 0000 0000 0000 0000  ................
000004F0 0000 0000 0000 0000 0000 0000 0000 A02A  .............. * (I$call vector)

Address   0 1  2 3  4 5  6 7  8 9  A B  C D  E F  0 2 4 6 8 A C E
-------- ---- ---- ---- ---- ---- ---- ---- ----  ----------------
00000500 0606 8885 837F 7D00 0000 0000 0000 0000  ......}.........  Process Descriptors
00000510 0000 0000 0000 0000 0000 0000 0000 0000  ................    base table (PrcDBT)
00000520 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000530 0000 0000 0000 0000 0000 0000 0000 0000  ................  Here: 0600 - n/a
00000540 0000 0000 0000 0000 0000 0000 0000 0000  ................        0600 - id 1
00000550 0000 0000 0000 0000 0000 0000 0000 0000  ................        8800 - id 2        
00000560 0000 0000 0000 0000 0000 0000 0000 0000  ................        8500 - id 3
00000570 0000 0000 0000 0000 0000 0000 0000 0000  ................        8300 - id 4
00000580 0000 0000 0000 0000 0000 0000 0000 0000  ................        ... 
00000590 0000 0000 0000 0000 0000 0000 0000 0000  ................ 
000005A0 0000 0000 0000 0000 0000 0000 0000 0000  ................
000005B0 0000 0000 0000 0000 0000 0000 0000 0000  ................
000005C0 0000 0000 0000 0000 0000 0000 0000 0000  ................
000005D0 0000 0000 0000 0000 0000 0000 0000 0000  ................
000005E0 0000 0000 0000 0000 0000 0000 0000 0000  ................
000005F0 0000 0000 0000 0000 0000 0000 0000 0000  ................

Address   0 1  2 3  4 5  6 7  8 9  A B  C D  E F  0 2 4 6 8 A C E
-------- ---- ---- ---- ---- ---- ---- ---- ----  ----------------
00000600 0100 0002 0000 0000 0000 FFFF A000 0000  ............ ...   The System (id 1)
00000610 0000 0000 0000 0000 0000 0000 0000 0000  ................     Process Descriptor
00000620 8E00 0000 0003 8E00 0000 0068 0000 0000  ...........h....
00000630 0101 0100 0000 0000 0000 0000 0000 0000  ................
00000640 0000 333E 333E 0008 0001 0002 0003 0007  ..3>3>..........   - DAT images
00000650 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000660 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000670 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000680 0000 0000 0000 0000 006B 0000 0000 0001  .........k......
00000690 0000 0000 0000 0000 0000 0000 0000 0000  ................
000006A0 0000 0000 0000 0000 0000 0000 0000 0000  ................
000006B0 0000 0000 0003 0004 0648 0200 0404 0600  .........H......
000006C0 0992 0600 FC73 F400 8006 0006 CFFE 26F4  ....|st.....O~&t
000006D0 5B00 0007 D02E 00EC 00EE 8806 DD00 0000  [...P..l.n..]...
000006E0 0007 05ED 0092 005A F006 EB00 0B40 1201  ...m...Zp.k..@..
000006F0 6800 0100 0003 0000 FF01 8003 0012 0000  h...............

Address   0 1  2 3  4 5  6 7  8 9  A B  C D  E F  0 2 4 6 8 A C E
-------- ---- ---- ---- ---- ---- ---- ---- ----  ----------------
00000700 0000 675A 0000 0000 1723 4E69 7472 4F53  ..gZ.....#NitrOS   - and its stack area
00000710 2D39 2F36 3830 3920 4C65 7665 6C20 B200  -9/6809 Level 2.
00000720 0000 0000 0000 0000 00D1 01F7 D8C6 0003  .........Q.wXF..
00000730 0740 0738 0A30 F690 08FA D000 28D0 0F06  .@.8.0v..zP.(P..
00000740 480F 1004 0406 0104 D01A 401E 4001 0086  H.......P.@.@...
00000750 4005 0006 4800 3F00 3F00 0285 0000 FF01  @...H.?.?.......
00000760 00F3 1807 D0F3 FE26 D400 D105 0504 0777  .s..Ps~&T.Q....w
00000770 F318 07D0 F3FE 26D4 0600 00BC 0002 0286  s..Ps~&T...<....
00000780 00F3 1807 D0F3 FE26 D402 0000 8600 0300  .s..Ps~&T.......
00000790 8600 95A5 0398 952A 07A1 F318 8840 0701  ...%...*.!s..@..
000007A0 8800 8840 0001 0001 8840 0200 0001 8800  ...@.....@......
000007B0 0300 07BB F318 07D0 F3FE 2601 05F0 160C  ...;s..Ps~&..p..
000007C0 1F0C 00F4 8840 09F4 0648 000C 000C 0002  ...t.@.t.H......
000007D0 89F4 F400 8800 0300 07E1 F318 07D0 F3FE  .tt......as..Ps~
000007E0 26F4 0000 0088 0006 0007 F494 C8F3 1807  &t........t.Hs..
000007F0 F4F3 0400 F402 0000 A88F 0000 A85B 9287  ts..t...(...([..

Address   0 1  2 3  4 5  6 7  8 9  A B  C D  E F  0 2 4 6 8 A C E
-------- ---- ---- ---- ---- ---- ---- ---- ----  ----------------
00000800 0000 0000 0000 0000 0000 0000 0000 0000  ................    System Stack Page
00000810 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000820 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000830 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000840 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000850 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000860 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000870 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000880 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000890 0000 0000 0000 0000 0000 0000 0000 0000  ................
000008A0 0000 0000 0000 0000 0000 0000 0000 0000  ................
000008B0 0000 0000 0000 D400 8300 0300 08C5 F318  ......T......Es.
000008C0 08D0 F3FE 26D4 0A00 0083 0000 4984 E298  .Ps~&T......I.b.
000008D0 EBD4 0483 0008 DEF3 1808 D0F3 FE26 D404  kT....^s..Ps~&T.
000008E0 0B8B 8B7B 8FFB 8B00 0D83 00A5 3215 8FFB  ...{.{.....%2..{
000008F0 CDAC FE17 85F4 D400 8300 90E4 0000 FDDD  M,~..tT....d..}]

Address   0 1  2 3  4 5  6 7  8 9  A B  C D  E F  0 2 4 6 8 A C E
-------- ---- ---- ---- ---- ---- ---- ---- ----  ----------------
00000900 0101 0101 0101 0101 0101 0101 0101 0101  ................   System 64K Page Map
00000910 0101 0101 0101 0101 0101 0101 0101 0101  ................
00000920 0000 0000 0000 0000 0000 0000 0000 0000  ................   Each byte = 1 page
00000930 0000 0000 0000 0000 0000 0000 0000 0000  ................     01 = in use
00000940 0000 0000 0000 0000 0000 0000 0000 0000  ................     00 = free
00000950 0000 0000 0000 0000 0000 0000 0000 0000  ................     80 = not RAM
00000960 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000970 0000 0000 0000 0000 0000 0000 0001 0101  ................   "SMap" reports this
00000980 0101 0101 0101 0101 0101 0101 0101 0101  ................
00000990 0101 0101 0101 0101 0101 0101 0101 0101  ................
000009A0 0101 0101 0101 0101 0101 0101 0101 0101  ................
000009B0 0101 0101 0101 0101 0101 0101 0101 0101  ................
000009C0 0101 0101 0101 0101 0101 0101 0101 0101  ................
000009D0 0101 0101 0101 0101 0101 0101 0101 0101  ................
000009E0 0101 0101 0101 0101 0101 0101 0101 0101  ................
000009F0 0101 0101 0101 0101 0101 0101 0101 0180  ................  (top page is I/O)

Address   0 1  2 3  4 5  6 7  8 9  A B  C D  E F  0 2 4 6 8 A C E
-------- ---- ---- ---- ---- ---- ---- ---- ----  ----------------
00000A00 0FF4 1EF1 0D06 0000 0FF4 1EF1 0E30 0001  .t.q.....t.q.0..   Module Directory
00000A10 0FF4 1EF1 1000 0000 0F10 6CF0 1200 0001  .t.q......lp....
00000A20 0F10 6CF0 1F41 0001 0F10 6CF0 285B 0002  ..lp.A....lp([..   Each entry is 8 bytes
00000A30 0F10 6CF0 28D0 001A 0F10 6CF0 3BBE 001A  ..lp(P....lp;>..     and contains..
00000A40 0F10 6CF0 3CAD 001A 0F10 6CF0 3CE2 0000  ..lp<-....lp<b..     2 bytes DAT image pointer
00000A50 0F10 6CF0 3D17 0000 0F10 6CF0 3D4C 0000  ..lp=.....lp=L..             0 if entry is unused.
00000A60 0F10 6CF0 3D81 0000 0F10 6CF0 3DB6 0006  ..lp=.....lp=6..     2 bytes Block Size
00000A70 0F10 6CF0 4532 0006 0F10 6CF0 4986 0006  ..lpE2....lpI...     2 bytes offset to module
00000A80 0F10 6CF0 49C5 0000 0F10 6CF0 4A02 0000  ..lpIE....lpJ...     2 bytes link count
00000A90 0F10 6CF0 4A3F 0002 0F10 6CF0 4C92 0002  ..lpJ?....lpL...    
00000AA0 0F10 6CF0 4CBA 0002 0F10 6CF0 4CE0 0001  ..lpL:....lpL`..   "mdir" reports this
00000AB0 0F10 6CF0 4EA8 0001 0F10 6CF0 4F0E 0006  ..lpN(....lpO...
00000AC0 0F10 6CF0 6A65 0001 0F10 6CF0 6B56 0000  ..lpje....lpkV..    
00000AD0 0F10 6CF0 6BA9 0001 0F10 6CF0 6BCB 0000  ..lpk)....lpkK..
00000AE0 0F10 6CF0 6C12 0001 0F10 6CF0 6C3E 0001  ..lpl.....lpl>..
00000AF0 0F10 6CF0 6C62 0000 0F10 6CF0 6CC9 0000  ..lplb....lplI..

Address   0 1  2 3  4 5  6 7  8 9  A B  C D  E F  0 2 4 6 8 A C E
-------- ---- ---- ---- ---- ---- ---- ---- ----  ----------------
00000B00 0000 01FF 0000 0000 0ED0 1D33 0000 0001  .........P.3....
00000B10 0ED0 1D33 01FF 0000 0ED0 1D33 0253 0000  .P.3.....P.3.S..
00000B20 0ED0 1D33 0810 0000 0ED0 1D33 0877 0000  .P.3.....P.3.w..
00000B30 0ED0 1D33 0AE9 0000 0ED0 1D33 0E8A 0000  .P.3.i...P.3....
00000B40 0ED0 1D33 0F88 0000 0ED0 1D33 0FD7 0000  .P.3.....P.3.W..
00000B50 0ED0 1D33 1086 0000 0ED0 1D33 1373 0000  .P.3.....P.3.s..
00000B60 0ED0 1D33 1450 0000 0ED0 1D33 163B 0000  .P.3.P...P.3.;..
00000B70 0ED0 1D33 1972 0000 0ED0 1D33 1A8F 0000  .P.3.r...P.3....
00000B80 0EC0 0136 0000 0001 0000 0000 0000 0000  .@.6............
00000B90 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000BA0 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000BB0 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000BC0 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000BD0 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000BE0 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000BF0 0000 0000 0000 0000 0000 0000 0000 0000  ................

Address   0 1  2 3  4 5  6 7  8 9  A B  C D  E F  0 2 4 6 8 A C E
-------- ---- ---- ---- ---- ---- ---- ---- ----  ----------------
00000C00 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000C10 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000C20 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000C30 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000C40 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000C50 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000C60 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000C70 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000C80 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000C90 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000CA0 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000CB0 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000CC0 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000CD0 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000CE0 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000CF0 0000 0000 0000 0000 0000 0000 0000 0000  ................

Address   0 1  2 3  4 5  6 7  8 9  A B  C D  E F  0 2 4 6 8 A C E
-------- ---- ---- ---- ---- ---- ---- ---- ----  ----------------
00000D00 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000D10 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000D20 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000D30 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000D40 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000D50 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000D60 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000D70 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000D80 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000D90 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000DA0 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000DB0 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000DC0 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000DD0 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000DE0 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000DF0 0000 0000 0000 0000 0000 0000 0000 0000  ................

Address   0 1  2 3  4 5  6 7  8 9  A B  C D  E F  0 2 4 6 8 A C E
-------- ---- ---- ---- ---- ---- ---- ---- ----  ----------------
00000E00 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000E10 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000E20 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000E30 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000E40 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000E50 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000E60 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000E70 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000E80 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000E90 0000 0000 0000 0000 0000 0000 0000 0000  ................    ?? and towards the end is the
00000EA0 0000 0000 0000 0000 0000 0000 0000 0000  ................    ?? temporary DATimage stack
00000EB0 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000EC0 0009 0000 0000 0000 0000 0000 0000 0000  ................
00000ED0 000B 0000 0000 0000 0000 0000 0000 0000  ................
00000EE0 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000EF0 0000 0000 0000 0000 0000 0000 0000 0000  ................

Address   0 1  2 3  4 5  6 7  8 9  A B  C D  E F  0 2 4 6 8 A C E
-------- ---- ---- ---- ---- ---- ---- ---- ----  ----------------
00000F00 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000F10 0001 0002 0003 0007 0000 0000 0000 0000  ................
00000F20 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000F30 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000F40 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000F50 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000F60 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000F70 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000F80 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000F90 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000FA0 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000FB0 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000FC0 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000FD0 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000FE0 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000FF0 0000 0000 0007 0000 0000 0000 0000 0000  ................   - end System Variables

                                                                     - begin CC3 global memory

Section 2

OS9 SYSTEM CALLS

The OS9 system service calls, a SWI2 opcode followed by the call number, are the only recommended means to utilize memory, I/O and program control. A process inherits the SWI vectors from its parent, but may change them by the FSSSWI call.

Most of the calls are handled by the OS9 or OS9P2 modules. Any I/O call is vectored to IOMAN, which does its own internal table look-up. Another exception is the get-time call, which is dealt with by the Clock module.

There are two tables that contain the call vectors. The first table is from $00300-003FF, and is the table for calls made while in the system state. The user call table is at $00400-004FF.

To be in the system state, a program must currently be executing code within a system, manager, or driver module. This mainly occurs because of a system call. In other words, once a SWI call is made, all calls made within that call are vectored by the system table.

There are three main reasons for having a system mode. First, if a program is aborted while doing I/O (system mode), the program must be allowed to release I/O resources for other programs to use. Second, path numbers used while in the system mode are the actual path desc block number, and so must be distinguished from a process's path table pointer. And third, since new SWI and IRQ vectors are set on entry to the system mode, time is saved by bypassing this set-system-mode sub.

When a SWI2 call is made, the registers are placed on the current process's stack, and the stack pointer is saved in the process descriptor for easy access by the system modules. This way, the modules can use all the registers (except the SP) with impunity, and they all know where to get parameters passed and where to return values. Each module may do a fair amount of SWI2 calls itself. Under Level One, that meant that you needed to keep a large stack area for your program. That's not so important under Level Two, as the system or process descriptor stack is used mostly instead.

The calls from $28-S33 are regarded as privileged calls, since they have resource allocation powers that would be dangerous if used by a passing (non-system) program module. They may only be used while in the system state.

SWI2 SERVICE REQUEST OS 9

USER SWI2 SYS SWI2 l l State=sys l DP = 0 DP = 0 U=SP, store PSSP U - SP Table=user (D. UsrDis) Table=sys (D . SysDis) l l BSR DOCall BSR DOCall States user l l l END END

Docall Subroutine

OS 9 Get PC off IRQ stack Get next byte (call) Inc stack PC past call byte l (I/O call >=S80 ?) n--------------- <ج . ly l Vector at table-2 (I/O) (Call >= $37?) y------- >. ln l l (vector=0?) y--------- >l l l Get call vector l l l l l JSR the Call vector "Illegal SVC" l . <--In (C set for err ? ) l ly l Return Reg. B=err code in B 1----------- >l l Return lower 4 bits of CC l END SUB

I/O Vector I/O SERVICE CALL IOMAN

USER SYS l l Table=CBC8 Table=CBEA l -- -- -- -- -- -- -- -- -- -- -- -- - ܚܒܗ -- -->1 l (call2S 90?) y----------------- > "Illegal SVC" ln Get call vector JUMP to vector (Hidden RTS to OS 9 Docall above)

SWI 01 FSLOAD IOMAN

Alloc temp proc desc Totram=0, Totmod=0 Set proc prty=caller's Open EXEC. path to file FŞAl1Tsk, D. Proc=temp Call ReadMod header l (MŞID 87CD okay?) n---------------------- > ly Call ReadMod rest l FŞVİModul into moddir err---------- > l (known module?) n---->update ly Tot MOC l - ܚܙܗ - -- -- -- - ܚ- -- -- -- ܚ- -->1 Set FoundMod flag D. Proc=caller proc Close EXEC. path Check Tot Ram-TotMod Release blocks unused Dealloc temp proc desc (FoundMod flag set?) n--> return err ly Return ptr to first rinodule l END

Subroutine ReadMod IOMAN

sub l ModSiz=ModSiz+request . K--n (ModSiz > Tot Ram?) ly Calc if of blocks needed Find free blocks and set=$01 Set into tempo proc desc dating Tot Ram=Tot Ram+ new blocks FŞSet Tsk: update dating l · wa o- - a-a aw · >l l Read in header/module l RTS

Verify Module

Call CRC check FŞFModul in ModDir .<-n (find same name?) l (revision higher on new 2) n---> ESKnwMdl ly DSSSLSSSLLLLSLLLSLSLSSLLSLSLMSLMSCSLCLSS > Set ModImg IMPIDAT MPtr MIDLink=0 MBSiz=up to and including module l ... <-n (module in another block?) l ly l Free other entry !------- > Mark BlkMap with "ModBlock" l END

SWI 02 EFŞUNILINK OS9P2

Calc proc desc dating block if (does BlkMap show module?) n----> okay end ly Decrement P$Link cnt Search ModDir l l < 1. - - - ഷ -- - - അജ്മ ---- l Next ModDir entry l (same MDSMPtr?) n----- ly (same block 2) n----- > ly MDSLink cnt-1 . K-n (link cnt=0 ?) l ly l Do IODEL if needed l Call ClearDir sub


>

Decrement P$Link cnt . K-n (link cnt=0 ?) l l ly l Mark PSDating blocks as free


>

ENO

Subroutine ClearDir OS9P2

sub l Get dir entry block Check BlkMap flag ------- >end if already clear Pt to ModDir ]<--------------- .<-n (blksthis entry?) l l ly l l End if MDSLink.<>0 l ------- > l Next ModDir entry l (last entry?) n------ >l ly Free BlkMap flags CLear Datmg Clear ModDir entry l RTS

SWI 03 F$FORK OS9P2

E"ŞAllPrc desc Copy parent's PSUser, Prior, DIO ISDoup std 0, 1 , 2 pathis Cali MakeProc FŞAll Tsk for child FSMove parameters to child map FSMove register stack from proc desc to map FŞDel Tsk of child Return child id to caller Set PSCID of parent, PSPID, PSSID of child Clear Sys State of chik d FSAProc: activate child l END

Subroutine MakeProc OS9P2

sub li FSSLink to module - ok--->. lok l FSLoad module l 1<------------------ l l (Prgrm/Systm+Objct?) n----- > era ly Set PSPModul FSMen for new D. Proc Set new register stack in proc desc l rts

SWI 4B F$AllPrc OS9P2

Check D. ProcIDBT table for free entry FSSrcMem 512 byte proc desc Set D. ProDBT entry l Set PŞID in proc desc Clear PSDATImg State = Sys State l END

SW I 3F FŞALLTSK OS 9P1 Quick End if has PSTask Call Res Tsk Cal Set TS k END SW 42 FSRESTSK OS 9 Point to D. Tasks table Skip first two (reserved for systm) Find free entry, mark it used Return entry number as task l END

SW 43 FŞRELTSK OS 9P1 Point to D. Tasks table Clear task entry unless is Sys Tsk l END

SW 4 1 FSSETTSK OS 9P1 Clear ImgChg flag in PS State Get PSTask Copy PSDATImg's to task map l END

Subroutine Check Task PS State has ImgChg flag set? n-->rts ly Cal Set Tsk l rts

SW II. O 4 FŞWAIT OS 9P2 (children?) n------------- > "No Children" error ly (any dead yet?) y----------------------- > . lin l Return Regs. A=0 Regs. D= ID/code Stop IRQ " s Fix sibling links Place proc at front of W. Queue Dealloc. child desc Make a fake RTI stack l FSN proc: start next process END l l <FSExit of child wakes parent> <Regs. D has child ID/code> l Get real SP l END

SWI 08 E"ŞSEND OS 9P2 (dest ID=02) y------ >Send signal to all ! ln Send to ID only l END X-->ه l Stop IRQ's l ... ---n (code=abort?) l ly l Make proc condemned state l--------- >1 (has signal?) y------- ln (signal=wake?) n————>error l -- -- -- - ܚ - -- -- -- - ܚ- -- -->1 Store signal Wake upo proc Signal=0 if signal=1 Insert proc in A. Queue l END of SUB

SW O6 F ŞEXIT OS 9P2 PS Signal = Regs. B Close all I/O paths Return data memory Unlink primary module l Point to our last child <--------- l -- - - -- سه -سسه ح- سمت -- مس -ست ست -->ه و l l ... <-n (is it dead?) l. Return proc desc's of all l ly l dead (FSExit "d) children. l Dealloc proc desc li 1------ >l l Zero parent ID l Live kids are now orphans. Point to sibling l l l S LS LS LS S S S S S > l (any children?) y-->l lin l (we have parent?) y------ X. If we are orphan ourselves ln l we exit quickly. Dealloc our proc desc l <--------- l l l If parent hasn't FSWaited, l we are marked as Dead for l parent's Wait or Exit. l l )?n (parent waiting -- -- -- -- -- ܚܗ ܗܗܗ ܗܗ ܗܗ ܚ-ܐ ܀ l ly Mark us as Take parent out of W. Queue Dead F$Activate parent Put ID/code in parent's Regs. D l Fix sibling links l Dealloc child proc desc l l > >l l D - POC = 0 0 0 0 l END

SWI 0 0 FSLINK OS 9P1 Type=Reg. A Name ptr=Reg. X Find module dir entry -err-––––– >$DD error li . <--y (reentrant ?) l lin l (link cnt=0 ?) n---------- > ŞD1 error 1 ly - - - - - - - >l l Inc link cnt Return type/lang/hdr/entry l END

SWI 0C E? ŞID OS 9P2 Get ID from Proc Des c Get User from Proc Des C Return ID in Reg. A Return User in Reg. Y l END

SWI 0D E"ŞSBPROR OS 9P2 ID# = Reg. A Find Pro C Des C for ID -err------ > " NOlt. Eo Oundo l (same index?) n-------------- > "Not Yours' ly New proc priority=Reg. B l END

SWN OE F'$SWI OS 9P2 Point to Proc Des C's SWI table Type= Reg. A (type>3?) у—————————————— >' Illegal SWI Code' in New vector=Reg. X l END

SWN OE” E"SPERR IOMAN Get Error Path (#2) from Proc Desc table Convert Reg. B code to ASCII number Print " ERROR ! " Print err number l END

SWI 15 FSTIME CLOCK Destination=Reg. X FSMove D. Time to dest l END SW 16 FSSETIME OS 9P1 Source=Reg. X Move source to D. Time FSLink to 'Clock ' l (error?) y------------- > "Unknown Module' ln Jmp to Clock init (after this Clock usually sets it's l own FS Setime call - see below) (END) System Module Init CLOCK Set constants/vars Insert Clock vector at D - IRQ FSSSVC new Time call l END


MASLLMLLLLSSSSLSSeeeSYALL S SAAA L LLL T LLTT LLYYML0LqL YqL 0LSLLL LLLHHLHHLL0LSLLSL0He MLLLL YsL LSsL LSLLLLLLSLLLLLSLLsL sBSSYesLsL ssL sGHqqLLsLLSLLCMSLLLSSSLLLSL0LLSLLMLSSLSLSL LSLSLLLLLSLLLLLSLLLLLLLYe LSqLSqLeqLe TeeekTeTqTTSLTSYLLLMLqSqL LALLLL LLLLLL SW 2A FŞIRÇo IOMAN LGGSLL0SGSLYssL sSsMsYLsLLSLLsYYS LLssLsL SYGsLCSLLLssLssG MSLGYLL0sLGSLSsLYYG GLLLYLLSLLsLYsL sSLSLssLsLYSLGLLLLSLLLL CLLSSSLLLSLLLL GHSLL LGLLLLLLLSLLY L0LLLLYLLLzLLLSLLSYYszs LS L sLYLLsYYsL LHHLMSS Get packet values Get max if IRO entries from INIT Point to poll table (<$62) l ... <--y (Reg. Xs O2) l lin l (maskine0?) y ----------- >eo l lin l Search for empty l l (no empties?) y------ > " Pol Table Foul o l l l Sort by priority l Insert new entry li l l END l tle K.I., ENTRY it . > -- -ܝ =ܗ =- ܚܘ ܗ- ܘ- 1 l Find entry by data address At INIT Modulee + S (OC Delete it is max entries. Move rest up in table l END POLLING TABLE ENTRY FORM: OO-O. Address of status port O2 Flip byte O3 Mask byte O4 is OS IRQ service address O6-O Storage memory address O8 Priority (0-low, 255-high) System Module IRQ Polling Routine IOMAN Point to polling table Get max if entries from INIT 1-------------------- X. aty em am Ks mäso mob mimo škmo > l Point to next entry l (end of table?) y--------- 1 -س----ه س----- حس----------- س---- > ln l 1<--------------------- l Get status byte Table Full Err Flip and Mask Return er OL <--n (found it?) ly Do service routine (error?) ln END HLHSL L0eskSkLSSLLLHHLHkqHGMSLSL kSkDke Sq eSLL LsqS Bk LkLu Lqeq BHS0lkku SqL L eDkkeqS 0eq00qL L0LS0 LSL eqSBessSqueu SSqSL eSee eSqDkSkMLBG00e Dk eeS LS LK YTkBLLLLSSSLSLMSLYsYY e eS YYYkSSHGBYBDksu sTsK YkL eee l g ar Kr y

2-3-1 ________________ NSIDE OS9 LEVEL The System Section 3

SWI 80/81 ISATTACH/DETACH IOMAN 0SLYkYYYYYLSL LL0 LLLSS LLLSSLLYk YYLLLLLLSYSSLYsqSqSLLLLLLLS LeSYLLLTMLLL YLLL eeLLLs LSL eL LLLLLLLLzLLeG LLLSLLLe seSL YSL SY 0LeLLeeLeL seSLLSSLLLLLLLLeeSLLL sSYLL Ks eYeSL l li l l l l l l l l l l l l l l l l l l l ... <--y (mem alloc " d?) l l 1 كه مسیه{ ・<ー一y l 1 -- -- <--n (any user?) ga- - - - - wakeup یعے سے - a > FSlink--device desc l --> (entry empty?) y-------------- > al ~ re ····· a (same desc?) (mem alloc " d?) y---------- > l l l ly l Insert in I/O queue l l li <------------------ l l Save entry ptr !<=== അം=====------------ l (same port add?) (same driver?) T 1 < - ܚܒ ܝܼܚܘ ܚܘܕ݂ ܚ- ܗ- -- -- -- ܕ -- -- ܒܗܘ ܗܐ (user cintaeO?) l SaVe ser Cint 1 <-- അ അ - - - - - - - - - - - - - v - v - --m l Point to next entry (a st?) ly (entry found?) ln Find empty spot (error ? ) y.---> 'Table Full" l yーーーーーーーーーーーーーー d ilin A11.ocate drvr. mem á c1ear Set V . Port add in mer Do driver init sub Insert device thle data l g • -- ra area VM MMM — ۔۔۔۔۔۔۔۔ wwM l (Check desc/dir vir modes) l (user cnt az 0 ?) (device share able?) m as a Increment u Ser Cint Return table entry in Regs. U l END

2-3-2

er - - - - - - - ->


o

(get header, device address) err---------------- Co FSlink--device driver l (get driver entry address) ܚܗ ܟ- -- -- ܗ - ܚ- -- -ܗ ܗ- ܗ- = - ܚ- -- -- -- ܫܹ d FSlink-file manager l (get mgir entry address) 1 > - ܚ -- -ܚ- -- -- ܫܒܗ ܒܘ ܚܘ - ܗܗܝ = = ܚܘ ܣܚ - ܬܸܒ l l Get nax of entries (INIT) IŞDETACH Get device table add (CS60) l Dec u Ser Cint Unlink desc Unlink driver Unlink mgr l END DEVICE TABLE ENTRY: O - Driver mod 2 — Static mem 4 – Desc mod 6 – Fille mgir mod 8 - User count "Illegal Mode" "Device Busy"

________________ INSIDE OS9 LEVEL The System Section 3

SWI 83 IŞDUP OMAN Get free path from Proc Desc error----> "Path Table Full Find path des c of old path erra» - - -> "Unknown Path o Increment path desc image cnt Return new Proc path ptir in Regis. B Y KeYeqeSLSLeeSeSLYeYLSeeeSL0eeLY LLLLYS LS YYS es YeeYSqY 3 - R 密°宾滨 SLYSLYkLLLSYLLLYYYSS0LLLLS SWI 83/84 ISCREATE/OPEN IOMAN qqSASSLLSSLLS ee SLS LLSLLLe LLL eeSe LLLeeLLeLkSAe LSeq euLq qL LLeLLLLL Leeeeeee LSLeeze Get free path from Proc Desc l Get requested mode Allocate path desc Do File Manager Create/Open l Put path desc in Proc path table Return Proc path number in Regs. A l END SWI 8 F ISCLOSE IOMAN quqSq Lsek AeSe iSLLL YSLLLes ssL sesseL SsL SuL L LLSLLeseSee eeeeLLLLSSSL sLLLLSSSLL sse s sseeYSLLSLLLSL kksLL LSLLLLLLSL sssDse seessL eSKYSLDsk YSs ssL YS L LLLLLLLs YSLLLLLLSL LLYSYYsLLLLSLY LSL LSS0LSSSLL LSL YsYSLLLLSSSLLLSLLLLLSLS Get Proc path ptr for A=pathi Zero that path iptor in Proc Desc Find path desc Decrement # of open images ... <--y (current proc ID?) ln Update I/O cqueue Save caller's stack in PD. REGS Do Fille Manager Close l Wake up proc“ s in pd. links l (proc. IDs path. ID?) n--->. ly l Clear path. ID l == r == -- - - -- > 1 <---------------- അrm 1 l (open images mes 0 ? ) n ----> . liy l ISOETACH device Kill path desc l l l <---------------- END l qSLMSHHHeSMSMB s sqL YsLTSLL L LSLLTkBLGSLSLSL eBek kkS BBukHkHH ssDS TST TSL LDqukuBksk LkSukD kkSkDLkLkkkkk LkHe kkSBLSSSBLsuSSqL TSKLT zLLLSeBikBBkB Skq GBSLLBLBHSLYYBT LsST LkL DkDDSLLLBTBLBLSSLSLMSLLLSYYkLDBDkDzB LDSLLLLSSSLLLSLGLLLLL 2-3-3 ________________ INSIDE OS9 LEVEL The System Section 3 zYY LLLL LS LS YeYe YL Lq 0SYSLYsLYLLLYLLSLLLSLLYLYL ee LSSSSS SW 86 IL SCHGDIR IOMAN Save SW code for later use Allocate temp path desc l Do File Manager Chgdir sub (RBFman finds dir desc LSN & dr and puts in Proc Desc) <---1-. - - - - - - - -- > . l l data dir exec dir l l (dec user cnt in device table for old dir" s device) (inc user cnt in device table for new dir" s device) (set new device table entry into Proc Desc) l Point to device table entry for this tempo path ISDetach drive FSDealloc64 - kill this temp path desc l END PROCESS DESCRIPTOR DEFAULT DIR ENTRIES data eKec from 20-2 25-26 Device table entry ptr IOMAN) 22 27 drive number (not used) (RBFman) 23一24 28-29 Dir file desc LSN (RBFman) SWI 8 9 SIREAD OMAN Find path desc l ( read at tr?) n--------------------- > "No Permission ly 1 <- 1 ? ------ അ------- ... <--n (path desc in use?) l l ly Place in I/O Queue l l wakeup ---------------- >l X ܚ- -ܗ =ܗ ܗܘ ܚ - - 1 l Do File Manager Read sub Wake up others in I/O Queue Clear path user if still us (PD, CPR) l S LLSL S LLSSLLSS S LSLSL x= s:3:s: 2-3-4 ________________ INSIDE OS9 LEVEL The System Section 3 Subroutine IOMAN ALLOCATE PATH DESCRIPTOR (Open, Create) Get p d " s base (D. Pth DBT) Allo cate 64 byte block Set user cnt=l, mode=mode requested l Point to pathname Skip blanks l .--y (lst char="/ ?) If / " , it's full pathname; l ln El se use default dirs for this l l process de scriptor . l dir type? l ـــــــــــــــ ۔۔۔۔۔۔۔۔ـ ـ ۔۔۔۔۔۔ ۔۔ــــــــ ـ ـ ـ ـ ـ ـ ــ ۔۔۔۔۔۔ ۔۔۔۔۔۔۔ ۔۔۔ l l l l data dir exec dir l (get device tible entry from Proc Desc) l l l (entrysO ?) y - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > , l n l l Point to device desc name l l l l l l> -- --سسه -- حسه ---- --[ l l Par se name of device l (error ? ) y - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > ln l l l Attach device l Save table ptr in path des c l l l (attach err?) y--------------------------- >l ln l l l Get device des c init si ze Move up to 32 bytes to path des c l END

Bad Pathname Deallo cate pd block l Error End

Section 4

IRQ HANDLING

I have included this general text for the hackers out there.

Technical notes on the flow of hardware interrupt handling in OS9 L-I CoCo ver1.X or 2.0, and OS9 L-II Gimix ver 2.0 or CoCo 1.X.

The 6809 has three hardware interrupt lines, NMI, FIRQ, and IRQ. This doc concentrates on the IRO, which is the one used by OS9 for it's clock and I/O device polling routines.

I'll cover the various paths OS9 may take when it receives an IRQ, which don the current level, revision & system state. Note that because I only touch on IRQ-related code, other variables are involved.

IRQs - CLOCKS and DEVICES

There are two main source catagories of IRQ's: clock and device. They're both vectored to the same handler at their start, but branch differently. (CoCo OS-9 adds the VIRQ and FIRQ, but they end up being treated as an IRQ.)

The timesharing type has to do with updating the D.Time variables and calling the kernal's D.Clock process-switching algorithm. It comes from a regular timed interrupt source, such as the 60Hz Vertical Sync on the CoCo, or a clock chip or timer on other systems.

The other type is from a device asking for service. Usually that device's driver has entered an FSIRO request, so that the OS will know where to vector, after the polling routine has found that IRQ source device.

BASIC INTERRUPT HANDLING

All 6809 machines fetch their cpu interrupt vectors from a ROM that can be read at logical addresses FFFX. The IRQ vector is at FFF8-F9.

 * Level- COCO 1/2 - The ROM in these computers vectored to 010C, which contains a BRA to 0121, which does a JMP (D.IRQ).
 * Level-l COCO 3 - The new ROM vectors IRQs to FEF7, where it does a LBRA to 010C, maintaining compatability with 1.X or 2.0 OS-9. See CoCo 1/2 above. L-II of course needs the FEXX page pseudo-vectors so that there is always IRQ handling code across all task maps.

Level-II Task Switching

In Level-II, interrupts are ROM-vectored to the code at the top of OS9p1. This code lies within the page that is mapped across all task maps (on some systems, an interrupt causes a hardware reset of the task register to the system map instead, so a user has the full 64K available). In either case, the task register is set to the SysTask, the Direct Page register is set to zero, and then-JMP D.IRQ) D.IRQ defaults to the IntXfr (interrupt transfer) code in OS9p2, which does what boils down to a JMP D.XIRQ). This is changed by the Clock module.

OS-9 VECTOR INITIALIZATION

When OS 9 first cranks up, it sets the following:

D. UsrIRQ - kernal user-ird routine D - SysIRQ -- system " both of which will and up JSR'ing D. Poll) D. SvolRQ - has D. SysIRQ in it D - IRQ — kernal, JMP [ID - SvcIRQ] D. Poll - kernal COMB, RTS

This means that initially all IRQ's go thru the kernal to D.SvcIRQ back to the kernal's own Sys/UsrIRQ code, which then calls D.Poll to find the source. As the kernal does not do polling, and IOMan isn't initialized yet, D.Poll returns an error. The Sys/UsrIRQ code then shuts off IRQ's by setting the CC bits as a precaution.

TRANSFER TO SYSTEM STATE - Level-1 or II

Whether a program is in the user or system state when an interrupt occurs affects what D.SvcIRQ contains.

If in user state, it contains the vector constant copied from D.UsrIRQ. The routine in OS9p1 at that address saves the task's SP, sets SWI vectors to use system vectors, and copies D.SysIRQ into D.SvcIRQ.

The OS9p1 routine at D. SysIRQ does not save or set up anything as you are already in the system state. This helps speed interrupt handling.

IOMAN INIT

When the first ISCall is made, the kernal links to and initializes IOMAN (I/OMANager). Ioman inserts a vector to itself in D.Poll. From then on, IRQ's still go thru the kernal D.SvcIRQ to the Sys/UsrIRQ code, but their call to D.Poll is now honored by ioman, which does the source searching (polling).

Also on the init call, ioman sets up several tables. These are the device table D.DevTbl), polling table D.PolTbl, and on the CoCo the VIRQ (virtual irq) table D.CltTab).

These tables will be used by ioman for keeping track of active devices, inserting and deleting FSIRQ entries, and by ioman's D.Poll routine in finding the source of an IRQ.

CLOCK INIT and OPERATION

We must include Clock modules here because they are important in the IRQ heirachy. A side note: some clock modules keep their device address in the MSSize (data size) portion of their module header.

Clock modules keep track of the real time. Interrupts usually are vectored almost directly to them, and they decide for themselves if a clock IRQ was involved. In effect, a special device driver IRQ routine.

They are not in a polling table because a) the clock must be serviced quickly, and b) they may jump directly or thru another module to the kernal's timesharing routine (D.Clock) and so cannot be called as a subroutine such as device IRQ handlers are.

When the first FSSTime call is made (best from SysGo), OS9p 1 links to any module called "Clock", and JSR's to it's entry point. There the Clock module inserts itself into the system D.IRQ vector, so that it gets called first.

After that, IRQ's come to Clock, who checks to see if it's timer was the source. If so, it updates the time variables as needed, and jumps via D.Clock to the kernal (L-II jumps via D.XIRQ to the kernal).

If the timer or clock chip was NOT the IRQ source, then Clockjumps D.SvcIRQ so that OS9 can check for the correct device.

Exception #1: on the CoCo L-1 ver1.X., the IRQ's go first to CCIO (so it could time the disk motors), then to Clock via D. AltRQ), then Clock continued by D.Clock).

Exception #2: on the CoCo L-1 ver2.0, Clock jumps via D. AltRQ to the CCIO keyboard scan. CCIO finishes the jump to D.Clock).

IOMAN IRQ POLL SYNOPSIS

As we know now, when the Clock's D.IRQ code finds that an IRQ has occurred from other than it's IRQ, the IOMan D. Poll vector is eventually called.

IOMan looks thru the Polling Table, which has been presorted by device priority. Each QSPOLL address is read, XOR'd with the QSFLIP byte, AND'd with the QSMASK byte, and if is not=S00 after all that, the QSSERV routine in the driver for that device is called to service and clear that IRQ.

If the driver service code finds that a mistake has been made in it's selection, it can set the C bit, and IOMan will continue the search thru the table. See D.SvcIRQ above.

IRQ FLOWCHARTS

CoCo Level I IRO l ROM: jimp (D. IRO] (was it clockirq?) y------------------- >update time nl. l jmp {D... SvocIRO) jmp [ D. Alt IRQ) (D. UsrIRO) –-– –– or ------ ( D. Sy s IRQ) scan keyboard l li jmp D. Clock) D. SvcIRQ = D. SysIRQ jsir [D. Poll) update ticks jsir [D. Poll) C----------- y (ticks>0 or Sys State?) l rtji nl l l LLLLLLSJSSSSSSSS SS S SS qS qSS qS MS BM MM MM MS MSqS MSq BSAqSSSqSqqMMM MSASAS qSS S S BSB S BSS BMS BSS MM M M SSAS SSAS SSS SSS S SS l choose next proc D - SvcIRO = D. U sr IRQ rt . D. Poll scan devices, do driver irq sub rts Level II IRO l ROM: jmp to allmap page (XFEXX) Task Reg = Sys Task jmp (D. IRQ) : (old L-II) : (CoCo L-II) : (was it clockirg?) y----------- > update time - - - - ->update time nl. l l D. SvotRQ = d. Poll D. SwcIRO is D. Clock D. SviciIRQ = D. Virq C- - - - - - - - - - l -- -- -- -- -- -- -- -- -- -- -- -- - ܚ- ܚ - ܚ ܚ- -- -- -- --> 1 jmp (D. XIRO] : (D. U sr IRQ) ------ or - - - - - - (D. SysIRQ) l l SP = D. Sys Stk jsir [D. SvcIRQ D. XIRQ=D. SysIRQ rt jsir [D. SvcIRQ) l (slice up?) n---------- ly l choose proc to run l l -- ܘܗܝ -- -- -- -- -- -- --.ܚ.ܚ.-ܐ 1 D. XIRO) = D Us rIRO D. Virq : switch task to user update Virg table rti call D. Poll if Virq jsir D. KibdIRQl scan D. Poll: D. Clock: check & do allarm sig find source, driver IRQ sub update ticks jmp (D. Clock) rts rt S (rts)


NOTES:

All code is OS9pl, except D.IRQ/D.Virq-->Clock, and D.Poll-->IOMan. In most cases, IRQ's (and FIRQ's) are not reenabled until the RTI.

The L-II D.Clock is a subroutine, but the L-ID.Clock both updates the ticks, and then falls through to the timeshare routine.

Notice that if an interrupt occurs while in, other processes get achance to run if the current process is out of time.

GENERAL NOTES: virqs end up as irqs

Just after the end of the OS 9p1 module are the offsets to the following default code within it: . Clock routine SW3 (these are D.X. . . in Level- II) SW2 . E" R.Q IRO SW . NMI

IRQ-RELATED DP.VARS and SYSTEM TABLES

The following are the Direct Page (S00XX) variables that have to do with interrupt processing, and their addresses on the CoCo and GIMIX machines. Each contains a two-byte vector to the code within a System module that handles it, or point to a table.

Your system may vary, so check your OS9Defs file, if you don't own one of those computers. Addresses are included simply to give a rock to cling to.

NAME L- -- D. Init 2A-2B 24-25 Init Module pointer D . DevrTbol 60 - 61, 8 O - 8l I/O Device Table pointer D - Po, Tbi 62-63 82 - 83 I/O Polling Table pointer D - E" R.Q 30-31 F6-Fi E" R.Q handler D - IRO 32-33 F8-F9 IRQ D , NMI 36-37 FC-FD NMI D. SvcIRQ 38-39 CE-CF IRQ vector set by Clock depending on IRQ type D - Pol 3A-3B 26-27 Source device polling routine D - At IRQ 6B-6C Alternate TRO: hook D. Clock 81-82 E0-E1 Kernal timeshare routine DCT 86—- 87 BO -B11 VIRO device entry table ptr D. Kod IRQ B2一B3 Keyboard scan D » XIRO E8-E9 Secondary IRQ vector set to D. U sr IRQ or D. SysIRQ

Then there are the Direct Page variables that contain initialized vector constants, so that interrupts may be handled differently depending upon the OS state:

D. UsrIRO 3C-3D CA-CB User state D. SwcIRO vector D. SysIRQ 3E-3F C4-C5 System state D. SvcIRO vector LLLLLLL S SLLLLL S S AAAAA AA AA AA SS S SS S S S S SqSqqSq q qqq qqS qSS AAASS SS SS SS qSS S S BSiS MS S S SMSS iS S S BS BS SSS SSS The size of these tables is calculated from the DEVCNT and POLCNT entries in the system INIT module. DEVICE TABLE ENTRIES VSDRIV 00-01 Driver module addrss WSSTAT 02-03 Device static storage WSDESC 04-05 Device Descriptor VSFMGR 06-07 Fille Manager VSUSRS O8 Device User Count DevSiz equ . POLLING TABLE ENTRIES OSPOLL 00-01 Polling address (device status byte address) CSFL, I P O 2 Filip byte for negative logic IRQ bits QSMASK 03 Mask byte for IRQ status bit OSSERV 04-05 Driver IRO service routine QSSTAT 06-07 Device static memory pointer Q.Ş.PRTY 08 Device polling priority (position in table) PoliSiz equ .