|
|
1.1 root 1: ;
2:
3: ; interrupt wrapping routines; these should just save registers and call
4:
5: ; the appropriate C handlers, unless speed is a major problem
6:
7: ;
8:
9: ; $Log: intr.s,v $
10:
11: ; Revision 1.5 1992/04/18 10:57:18 AGK
12:
13: ; More +8s for 0.94
14:
15: ;
16:
17: ; Revision 1.4 1992/04/04 16:05:54 AGK
18:
19: ; Added some missing +8s in the vector pushes to allow for XBRA support
20:
21: ;
22:
23: ; Revision 1.3 1992/03/31 14:02:08 AGK
24:
25: ; Fixed for real Motorola syntax (many thanks to ERS for keeping these
26:
27: ; files in step with the GAS ones).
28:
29: ;
30:
31: ; Revision 1.2 1992/03/31 13:55:28 AGK
32:
33: ; Checked in MiNT 0.93 sources
34:
35: ;
36:
37: ; Revision 1.1 1991/05/30 17:22:18 AGK
38:
39: ; Initial revision
40:
41: ;
42:
43: SECTION TEXT
44:
45: ;
46:
47: ; first, utilities for setting processor status level
48:
49: ;
50:
51: XDEF _spl7,_spl
52:
53: _spl7:
54:
55: move.w sr,d0
56:
57: ori.w #$0700,sr
58:
59: rts
60:
61: _spl:
62:
63: move.w 4(sp),d0
64:
65: move.w d0,sr
66:
67: rts
68:
69:
70:
71: XDEF _mint_5ms
72:
73: XDEF _mint_timer
74:
75: XDEF _mint_vbl
76:
77: XREF _timeout ; C time routine
78:
79: XREF _old_timer ; old GEMDOS time vector
80:
81: XREF _old_vbl ; old GEMDOS vbl vector
82:
83: XREF _old_5ms
84:
85: XREF _build_context
86:
87: XREF _restore_context
88:
89: XREF _proc_clock ; controls process' allocation of CPU time
90:
91: XREF _curproc
92:
93: XREF _enter_kernel
94:
95: XREF _leave_kernel
96:
97: XREF _preempt
98:
99: XREF _in_kernel
100:
101:
102:
103: ; AKP: this code is hit once every 5ms; it updates the time fields of curproc.
104:
105: _mint_5ms:
106:
107: move.l a0,-(sp)
108:
109: move.l _curproc,a0
110:
111: add.w #$364,a0 ; $364 is offset to curproc->systime;
112:
113: tst.w _in_kernel
114:
115: bne L_5a ; usrtime is the branch-not-taken case
116:
117: addq.l #4,a0
118:
119: L_5a: addq.l #5,(a0)
120:
121: move.l (sp)+,a0
122:
123: move.l _old_5ms+8,-(sp)
124:
125: rts
126:
127:
128:
129: _mint_timer:
130:
131: movem.l d0-d2/a0-a2,-(sp) ; save C registers
132:
133: jsr _timeout
134:
135: movem.l (sp)+,d0-d2/a0-a2
136:
137: move.l _old_timer+8,-(sp) ; jump to GEMDOS time vector
138:
139: rts
140:
141:
142:
143: _mint_vbl:
144:
145: tst.w ($59e).w ; test longframe (AKP)
146:
147: beq.s L_short1
148:
149: clr.w -(sp) ; yes, long frames: push a frame word
150:
151: L_short1:
152:
153: pea L_comeback ; push fake PC
154:
155: move.w sr,-(sp) ; push status register
156:
157: move.l _old_vbl+8,-(sp) ; go service the interrupt
158:
159: rts
160:
161:
162:
163: L_comeback:
164:
165: tst.w _proc_clock ; has time expired yet?
166:
167: beq.s L_expired ; yes -- maybe go switch processes
168:
169: L_out:
170:
171: rte ; no -- just return
172:
173:
174:
175: L_expired:
176:
177: btst #13,(sp) ; user mode?
178:
179: bne.s L_out ; no -- switching is not possible
180:
181: L_switch:
182:
183: move.l _curproc,-(sp)
184:
185: addq.l #4,(sp) ; to get &curproc->ctxt[SYSCALL]
186:
187: jsr _build_context ; build context
188:
189: move.l _curproc,a0
190:
191: move.l (a0),sp ; use curproc->sysstack
192:
193: jsr _enter_kernel ; enter kernel
194:
195: jsr _preempt ; yield processor
196:
197: ori.w #$700,sr ; spl7()
198:
199: jsr _leave_kernel ; restore vectors
200:
201: move.l _curproc,a0
202:
203: pea 4(a0)
204:
205: jsr _restore_context ; back to user
206:
207:
208:
209: ;
210:
211: ; reset routine -- called on a warm boot. Note that TOS sends the
212:
213: ; address to which we should return in register a6. Also note that
214:
215: ; the stack pointer is in an unknown state, so we set up our own
216:
217: ;
218:
219: XDEF _reset
220:
221: XREF _tmpstack ; see main.c
222:
223: XREF _restr_intr
224:
225:
226:
227: _reset:
228:
229: move.w #$2700,sr ; avoid interruption here
230:
231: move.l sp,_tmpstack ; save A7
232:
233: lea _tmpstack,sp ; set up temporary stack
234:
235: lea 256(sp),sp
236:
237: movem.l d0-d2/a0-a2,-(sp) ; save C registers
238:
239: jsr _restr_intr ; restore interrupts
240:
241: movem.l (sp)+,d0-d2/a0-a2 ; restore registers
242:
243: move.l _tmpstack,sp
244:
245: jmp (a6) ; reset again
246:
247:
248:
249: ;
250:
251: ; routine for doing a reboot
252:
253: ;
254:
255: XDEF _reboot
256:
257: _reboot:
258:
259: move.w #$2700,sr ; avoid interrupts
260:
261: move.l (0).w,sp ; get sp after reboot
262:
263: move.l (4).w,a6 ; get new reboot address
264:
265: jmp _reset
266:
267:
268:
269: ;
270:
271: ; routine for mouse packet handling
272:
273: ;
274:
275: XDEF _newmvec
276:
277: XREF _mouse_handler
278:
279:
280:
281: _newmvec:
282:
283: move.l a0,-(sp)
284:
285: jsr _mouse_handler
286:
287: move.l (sp)+,a0
288:
289: rts
290:
291:
292:
293: ;
294:
295: ; new ikbd keyboard interrupt vector
296:
297: ; kintr is a global variable that should be non-zero if a keyboard
298:
299: ; event occured
300:
301: ;
302:
303: XDEF _new_ikbd
304:
305: XREF _old_ikbd
306:
307: XREF _kintr
308:
309:
310:
311: _new_ikbd:
312:
313: move.w #1,_kintr
314:
315: move.l _old_ikbd+8,-(sp)
316:
317: rts ; jump to system interrupt routine
318:
319:
320:
321: ;
322:
323: ; simple signal handlers
324:
325: ; global variables referenced:
326:
327: ; in_kernel: (main.c): flag to indicate that we're in the MiNT kernel
328:
329: ; sig_routine: (signal.c): pointer to which signal catching routine to
330:
331: ; call (e.g. for SIGBUS, or whatever)
332:
333: ;
334:
335: XDEF _new_bus,_new_addr,_new_ill,_new_divzero,_new_priv
336:
337: XDEF _new_trace
338:
339: XREF _in_kernel,_sig_routine
340:
341: XREF _sigbus,_sigaddr,_sigill,_sigfpe,_sigpriv,_sigtrap
342:
343:
344:
345: _new_bus:
346:
347: move.l #_sigbus,_sig_routine
348:
349: Do_sig:
350:
351: tst.w _in_kernel ; are we already in the kernel?
352:
353: bne.s Kernel ; yes
354:
355: move.l _curproc,-(sp)
356:
357: add.l #4,(sp) ; push offset of save area
358:
359: jsr _build_context
360:
361: move.l _curproc,a4
362:
363: move.l (a4),sp ; put us in the system stack
364:
365: jsr _enter_kernel ; set up kernel vectors
366:
367: move.l _sig_routine,a1 ; get signal handling routine
368:
369: jsr (a1) ; go do it
370:
371: ori.w #$0700,sr ; spl7()
372:
373: jsr _leave_kernel ; leave kernel
374:
375: lea 4(a4),a4 ; get context save area address
376:
377: move.l a4,-(sp) ; push it
378:
379: jsr _restore_context ; restore the context
380:
381: ;
382:
383: ; here's what we do if we already were in the kernel
384:
385: ;
386:
387: Kernel:
388:
389: movem.l d0-d2/a0-a2,-(sp) ; save reggies
390:
391: move.l _sig_routine,a1 ; get handler
392:
393: jsr (a1) ; go do it
394:
395: movem.l (sp)+,d0-d2/a0-a2
396:
397: rte
398:
399: _new_addr:
400:
401: move.l #_sigaddr,_sig_routine
402:
403: bra.s Do_sig
404:
405: _new_ill:
406:
407: move.l #_sigill,_sig_routine
408:
409: bra.s Do_sig
410:
411: _new_divzero:
412:
413: move.l #_sigfpe,_sig_routine
414:
415: bra.s Do_sig
416:
417: _new_priv:
418:
419: move.l #_sigpriv,_sig_routine
420:
421: bra Do_sig
422:
423: _new_trace:
424:
425: move.l #_sigtrap,_sig_routine
426:
427: bra Do_sig
428:
429:
430:
431: ;
432:
433: ; BIOS disk vectors for pseudo-disks like U: and X:; these are present
434:
435: ; just in case some program (foolishly) attempts to access these drives
436:
437: ; directly and gets horribly confused
438:
439: ;
440:
441: XREF _old_getbpb ; old Getbpb vector
442:
443: XREF _old_mediach ; old Mediach vector
444:
445: XREF _old_rwabs ; old Rwabs vector
446:
447: XDEF _new_getbpb
448:
449: XDEF _new_mediach
450:
451: XDEF _new_rwabs
452:
453:
454:
455: _new_getbpb:
456:
457: move.w 4(sp),d0 ; check the drive
458:
459: cmp.w #$10,d0 ; drive Q:?
460:
461: beq.s nobpb ; yes, no BPB available
462:
463: cmp.w #$14,d0 ; drive U:?
464:
465: beq.s nobpb ; yes, no BPB available
466:
467: cmp.w #$15,d0 ; drive V:?
468:
469: beq.s nobpb
470:
471: cmp.w #$17,d0 ; drive X:?
472:
473: beq.s nobpb
474:
475: move.l _old_getbpb+8,a0 ; not our drive
476:
477: jmp (a0) ; call the old vector for it
478:
479: nobpb:
480:
481: moveq.l #0,d0 ; 0 means "no BPB read"
482:
483: rts
484:
485:
486:
487: _new_mediach:
488:
489: move.w 4(sp),d0 ; check the drive
490:
491: cmp.w #$10,d0 ; drive Q:?
492:
493: beq.s nochng ; yes, no change
494:
495: cmp.w #$14,d0 ; drive U:?
496:
497: beq.s nochng ; yes, no change
498:
499: cmp.w #$15,d0 ; drive V:?
500:
501: beq.s nochng
502:
503: cmp.w #$17,d0 ; drive X:?
504:
505: beq.s nochng
506:
507: move.l _old_mediach+8,a0 ; not our drive
508:
509: jmp (a0) ; call the old vector for it
510:
511: nochng:
512:
513: moveq.l #0,d0 ; 0 means "definitely no change"
514:
515: rts
516:
517:
518:
519: _new_rwabs:
520:
521: move.w $e(sp),d0 ; check the drive
522:
523: cmp.w #$10,d0 ; drive Q:?
524:
525: beq.s rwdone ; yes, fake a successful I/O operation
526:
527: cmp.w #$14,d0 ; drive U:?
528:
529: beq.s rwdone ; yes, fake it
530:
531: cmp.w #$15,d0 ; drive V:?
532:
533: beq.s rwdone
534:
535: cmp.w #$17,d0 ; drive X:?
536:
537: beq.s rwdone
538:
539: move.l _old_rwabs+8,a0 ; not our drive
540:
541: jmp (a0) ; call the old vector for it
542:
543: rwdone:
544:
545: moveq.l #0,d0 ; 0 means "successful operation"
546:
547: rts
548:
549:
550:
551: END
552:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.