comparison level1/modules/clock2_elim.asm @ 1724:f389c6bca482

New clock2_*.asm files split from single clock2.asm for more source clarity
author boisy
date Fri, 20 Aug 2004 11:11:58 +0000
parents
children
comparison
equal deleted inserted replaced
1723:00d6e3a47987 1724:f389c6bca482
1 ********************************************************************
2 * Clock2 - Eliminator RTC Driver
3 *
4 * $Id$
5 *
6 * Edt/Rev YYYY/MM/DD Modified by
7 * Comment
8 * ------------------------------------------------------------------
9 * 1 2004/08/18 Boisy G. Pitre
10 * Separated clock2 modules for source clarity.
11
12 nam Clock2
13 ttl Eliminator RTC Driver
14
15 ifp1
16 use defsfile
17 endc
18
19 tylg set Sbrtn+Objct
20 atrv set ReEnt+rev
21 rev set $00
22 edition set 1
23
24 RTC.Sped equ $20 32.768 KHz, rate=0
25 RTC.Strt equ $06 binary, 24 Hour, DST disabled
26 RTC.Stop equ $86 bit 7 set stops clock to allow setting time
27 RTC.Base equ $FF72 I don't know base for this chip.
28
29 mod eom,name,tylg,atrv,JmpTable,RTC.Base
30
31 name fcs "Clock2"
32 fcb edition
33
34 JmpTable
35 lbra Init
36 bra GetTime
37 nop
38 lbra SetTime
39
40
41 GetTime ldx M$Mem,pcr get RTC base address from fake memory requirement
42 ldb #$0A UIP status register address
43 stb ,x generate address strobe
44 lda 1,x get UIP status
45 bpl NoUIP Update In Progress, go shift next RTC read
46 lda #TkPerSec/2 set up next RTC read attempt in 1/2 second
47 sta <D.Tick save tick
48 bra UpdTExit and return
49
50 NoUIP decb year register address
51 stb ,x generate address strobe
52 lda 1,x get year
53 sta <D.Year
54 decb month register address
55 stb ,x
56 lda 1,x
57 sta <D.Month
58 decb day of month register address
59 stb ,x
60 lda 1,x
61 sta <D.Day
62 ldb #4 hour register address
63 stb ,x
64 lda 1,x
65 sta <D.Hour
66 ldb #2 minute register address
67 stb ,x
68 lda 1,x
69 sta <D.Min
70 clrb second register address
71 stb ,x
72 lda 1,x
73 SaveSec sta <D.Sec
74 UpdTExit rts
75
76
77
78 SetTime pshs cc save interrupt status
79 orcc #IntMasks disable IRQs
80 ldx M$Mem,pcr get RTC base address from fake memory requirement
81 ldy #D.Time point [Y] to time variables in DP
82 ldd #$0B*256+RTC.Stop
83 bsr UpdatCk0 stop clock before setting it
84 ldb #RTC.Sped
85 bsr UpdatCk0 set crystal speed, output rate
86 bsr UpdatClk go set year
87 bsr UpdatClk go set month
88 bsr UpdatClk go set day of month
89 bsr UpdatCk0 go set day of week (value doesn't matter)
90 bsr UpdatCk0 go set hours alarm (value doesn't matter)
91 bsr UpdatClk go set hour
92 bsr UpdatCk0 go set minutes alarm (value doesn't matter)
93 bsr UpdatClk go set minute
94 bsr UpdatCk0 go set seconds alarm (value doesn't matter)
95 bsr UpdatClk go set second
96 ldd #$0B*256+RTC.Strt
97 bsr UpdatCk0 go start clock
98 puls cc Recover IRQ status
99 clrb
100 rts
101
102 UpdatClk ldb ,y+ get data from D.Time variables in DP
103 UpdatCk0 std ,x generate address strobe, save data
104 deca set [A] to next register down
105 rts
106
107 IFGT Level-1
108 * OS-9 Level Two code only (for now)
109 NewSvc fcb F$NVRAM Eliminator adds one new service call
110 fdb F.NVRAM-*-2
111 fcb $80 end of service call installation table
112
113 *------------------------------------------------------------
114 * read/write RTC Non Volatile RAM (NVRAM)
115 *
116 * INPUT: [U] = pointer to caller's register stack
117 * R$A = access mode (1 = read, 2 = write, other = error)
118 * R$B = byte count (1 through 50 here, but in other implementations
119 * may be 1 through 256 where 0 implies 256)
120 * R$X = address of buffer in user map
121 * R$Y = start address in NVRAM
122 *
123 * OUTPUT: RTC NVRAM read/written
124 *
125 * ERROR OUTPUT: [CC] = Carry set
126 * [B] = error code
127 F.NVRAM tfr u,y copy caller's register stack pointer
128 ldd #$0100 ask for one page
129 os9 F$SRqMem
130 bcs NVR.Exit go report error...
131 pshs y,u save caller's stack and data buffer pointers
132 ldx R$Y,y get NVRAM start address
133 cmpx #50 too high?
134 bhs Arg.Err yes, go return error...
135 ldb R$B,y get NVRAM byte count
136 beq Arg.Err
137 abx check end address
138 cmpx #50 too high?
139 bhi Arg.Err yes, go return error...
140 lda R$A,y get direction flag
141 cmpa #WRITE. put caller's data into NVRAM?
142 bne ChkRead no, go check if read...
143 clra [D]=byte count
144 pshs d save it...
145 ldx <D.Proc get caller's process descriptor address
146 lda P$Task,x caller is source task
147 ldb <D.SysTsk system is destination task
148 ldx R$X,y get caller's source pointer
149 puls y recover byte count
150 os9 F$Move go MOVE data
151 bcs NVR.Err
152 ldy ,s get caller's register stack pointer from stack
153 lda R$Y+1,y get NVRAM start address
154 adda #$0E add offset to first RTC NVRAM address
155 ldb R$B,y get byte count
156 ldx M$Mem,pcr get clock base address from fake memory requirement
157 pshs cc,b save IRQ enable status and byte counter
158 orcc #IntMasks disable IRQs
159 WrNVR.Lp ldb ,u+ get caller's data
160 std ,x generate RTC address strobe and save data to NVRAM
161 inca next NVRAM address
162 dec 1,s done yet?
163 bne WrNVR.Lp no, go save another byte
164 puls cc,b recover IRQ enable status and clean up stack
165 NVR.RtM puls y,u recover register stack & data buffer pointers
166 ldd #$0100 return one page
167 os9 F$SRtMem
168 NVR.Exit rts
169
170 Arg.Err ldb #E$IllArg Illegal Argument error
171 bra NVR.Err
172
173 ChkRead cmpa #READ. return NVRAM data to caller?
174 bne Arg.Err illegal access mode, go return error...
175 lda R$Y+1,y get NVRAM start address
176 adda #$0E add offset to first RTC NVRAM address
177 ldx M$Mem,pcr get clock base address from fake memory requirement
178 pshs cc,b save IRQ enable status and byte counter
179 orcc #IntMasks disable IRQs
180 RdNVR.Lp sta ,x generate RTC address strobe
181 ldb 1,x get NVRAM data
182 stb ,u+ save it to buffer
183 inca next NVRAM address
184 dec 1,s done yet?
185 bne RdNVR.Lp no, go get another byte
186 puls cc,a recover IRQ enable status, clean up stack ([A]=0)
187 ldb R$B,y [D]=byte count
188 pshs d save it...
189 ldx <D.Proc get caller's process descriptor address
190 ldb P$Task,x caller is source task
191 lda <D.SysTsk system is destination task
192 ldu R$X,y get caller's source pointer
193 puls y recover byte count
194 ldx 2,s get data buffer (source) pointer
195 os9 F$Move go MOVE data
196 bcc NVR.RtM
197 NVR.Err puls y,u recover caller's stack and data pointers
198 pshs b save error code
199 ldd #$0100 return one page
200 os9 F$SRtMem
201 comb set Carry for error
202 puls b,pc recover error code, return...
203 ENDC
204
205
206 Init equ *
207 IFGT Level-1
208 * Eliminator will install specific system calls
209 leay NewSvc,pcr insert syscalls
210 os9 F$SSvc
211 ENDC
212 rts
213
214 emod
215 eom equ *
216 end
217