1
2
3
4
5
6
7 #include <asm/system.h>
8
9 #define halt .long PAL_halt
10 #define rti .long PAL_rti
11 #define SIGCHLD 20
12
13 #define NR_SYSCALLS 350
14 #define osf_vfork sys_fork
15
16
17
18
19 #define HAE_CACHE 0
20 #define HAE_REG 8
21
22
23
24
25 #define SP_OFF 160
26
27 #define SWITCH_STACK_SIZE 320
28
29
30
31
32 #define TASK_STATE 0
33 #define TASK_COUNTER 8
34 #define TASK_PRIORITY 16
35 #define TASK_SIGNAL 24
36 #define TASK_BLOCKED 32
37 #define TASK_FLAGS 40
38
39
40
41
42 #define PF_PTRACED 0x00000010
43
44
45
46
47
48
49
50
51 #define SAVE_ALL \
52 subq $30,160,$30; \
53 stq $0,0($30); \
54 stq $1,8($30); \
55 stq $2,16($30); \
56 stq $3,24($30); \
57 stq $4,32($30); \
58 stq $5,40($30); \
59 stq $6,48($30); \
60 stq $7,56($30); \
61 stq $8,64($30); \
62 stq $19,72($30); \
63 stq $20,80($30); \
64 stq $21,88($30); \
65 stq $22,96($30); \
66 stq $23,104($30); \
67 stq $24,112($30); \
68 stq $25,120($30); \
69 stq $26,128($30); \
70 stq $27,136($30); \
71 stq $28,144($30); \
72 lda $2,hae; \
73 ldq $2,HAE_CACHE($2); \
74 stq $2,152($30)
75
76 #define RESTORE_ALL \
77 lda $8,hae; \
78 ldq $7,HAE_CACHE($8); \
79 ldq $6,152($30); \
80 subq $7,$6,$5; \
81 beq $5,99f; \
82 ldq $7,HAE_REG($8); \
83 addq $31,7,$16; \
84 call_pal PAL_swpipl; \
85 stq $6,HAE_CACHE($8); \
86 stq $6,0($7); \
87 mb; \
88 bis $0,$0,$16; \
89 call_pal PAL_swpipl; \
90 99:; \
91 ldq $0,0($30); \
92 ldq $1,8($30); \
93 ldq $2,16($30); \
94 ldq $3,24($30); \
95 ldq $4,32($30); \
96 ldq $5,40($30); \
97 ldq $6,48($30); \
98 ldq $7,56($30); \
99 ldq $8,64($30); \
100 ldq $19,72($30); \
101 ldq $20,80($30); \
102 ldq $21,88($30); \
103 ldq $22,96($30); \
104 ldq $23,104($30); \
105 ldq $24,112($30); \
106 ldq $25,120($30); \
107 ldq $26,128($30); \
108 ldq $27,136($30); \
109 ldq $28,144($30); \
110 addq $30,160,$30
111
112 .text
113 .set noat
114 #ifdef __linux__
115 .set singlegp
116 #endif
117
118 .align 3
119 .globl entInt
120 .ent entInt
121 entInt:
122 SAVE_ALL
123
124 lda $0,intr_count
125 ldq $1,0($0)
126 addq $1,1,$1
127 stq $1,0($0)
128
129 lda $27,do_entInt
130 jsr $26,($27),do_entInt
131
132 lda $0,intr_count
133 ldq $1,0($0)
134 subq $1,1,$1
135 stq $1,0($0)
136 br $31,ret_from_sys_call
137 .end entInt
138
139 .align 3
140 .globl entMM
141 .ent entMM
142 entMM:
143 SAVE_ALL
144 lda $27,do_page_fault
145 lda $26,ret_from_sys_call
146 jsr $31,($27),do_page_fault
147 .end entMM
148
149 .align 3
150 .globl entArith
151 .ent entArith
152 entArith:
153 SAVE_ALL
154 lda $27,do_entArith
155 lda $26,ret_from_sys_call
156 jsr $31,($27),do_entArith
157 .end entArith
158
159 .align 3
160 .globl entIF
161 .ent entIF
162 entIF:
163 SAVE_ALL
164 lda $27,do_entIF
165 lda $26,ret_from_sys_call
166 jsr $31,($27),do_entIF
167 .end entIF
168
169
170
171
172
173
174
175
176
177
178 .align 3
179 .ent kernel_clone
180 kernel_clone:
181 subq $30,6*8,$30
182 stq $31,0($30)
183 stq $26,8($30)
184 stq $29,16($30)
185 stq $16,24($30)
186 stq $17,32($30)
187 stq $18,40($30)
188 bis $31,2,$0
189 SAVE_ALL
190 lda $27,sys_clone
191 jsr $26,($27),sys_clone
192 stq $0,0($30)
193 br $31,ret_from_sys_call
194 .end kernel_clone
195
196
197
198
199 .align 3
200 .globl __kernel_thread
201 .ent __kernel_thread
202 __kernel_thread:
203 subq $30,4*8,$30
204 stq $9,0($30)
205 stq $10,8($30)
206 stq $26,16($30)
207 bis $17,$17,$9
208 bis $18,$18,$10
209 bsr $26,kernel_clone
210 bne $20,1f
211 ldq $9,0($30)
212 ldq $10,8($30)
213 ldq $26,16($30)
214 addq $30,4*8,$30
215 ret $31,($26),1
216
217 1: bis $9,$9,$27
218 bis $10,$10,$16
219 jsr $26,($27)
220 bis $0,$0,$16
221 lda $27,sys_exit
222 jsr $26,($27),sys_exit
223 call_pal PAL_halt
224 .end __kernel_thread
225
226 .align 3
227 .ent do_switch_stack
228 do_switch_stack:
229 lda $30,-SWITCH_STACK_SIZE($30)
230 stq $9,0($30)
231 stq $10,8($30)
232 stq $11,16($30)
233 stq $12,24($30)
234 stq $13,32($30)
235 stq $14,40($30)
236 stq $15,48($30)
237 stq $26,56($30)
238 stt $f0,64($30)
239 stt $f1,72($30)
240 stt $f2,80($30)
241 stt $f3,88($30)
242 stt $f4,96($30)
243 stt $f5,104($30)
244 stt $f6,112($30)
245 stt $f7,120($30)
246 stt $f8,128($30)
247 stt $f9,136($30)
248 stt $f10,144($30)
249 stt $f11,152($30)
250 stt $f12,160($30)
251 stt $f13,168($30)
252 stt $f14,176($30)
253 stt $f15,184($30)
254 stt $f16,192($30)
255 stt $f17,200($30)
256 stt $f18,208($30)
257 stt $f19,216($30)
258 stt $f20,224($30)
259 stt $f21,232($30)
260 stt $f22,240($30)
261 stt $f23,248($30)
262 stt $f24,256($30)
263 stt $f25,264($30)
264 stt $f26,272($30)
265 stt $f27,280($30)
266 mf_fpcr $f0 # get fpcr
267 stt $f28,288($30)
268 stt $f29,296($30)
269 stt $f30,304($30)
270 stt $f0,312($30) # save fpcr in slot of $f31
271 ret $31,($1),1
272 .end do_switch_stack
273
274 .align 3
275 .ent undo_switch_stack
276 undo_switch_stack:
277 ldq $9,0($30)
278 ldq $10,8($30)
279 ldq $11,16($30)
280 ldq $12,24($30)
281 ldq $13,32($30)
282 ldq $14,40($30)
283 ldq $15,48($30)
284 ldq $26,56($30)
285 ldt $f30,312($30) # get saved fpcr
286 ldt $f0,64($30)
287 ldt $f1,72($30)
288 ldt $f2,80($30)
289 ldt $f3,88($30)
290 mt_fpcr $f30 # install saved fpcr
291 ldt $f4,96($30)
292 ldt $f5,104($30)
293 ldt $f6,112($30)
294 ldt $f7,120($30)
295 ldt $f8,128($30)
296 ldt $f9,136($30)
297 ldt $f10,144($30)
298 ldt $f11,152($30)
299 ldt $f12,160($30)
300 ldt $f13,168($30)
301 ldt $f14,176($30)
302 ldt $f15,184($30)
303 ldt $f16,192($30)
304 ldt $f17,200($30)
305 ldt $f18,208($30)
306 ldt $f19,216($30)
307 ldt $f20,224($30)
308 ldt $f21,232($30)
309 ldt $f22,240($30)
310 ldt $f23,248($30)
311 ldt $f24,256($30)
312 ldt $f25,264($30)
313 ldt $f26,272($30)
314 ldt $f27,280($30)
315 ldt $f28,288($30)
316 ldt $f29,296($30)
317 ldt $f30,304($30)
318 lda $30,SWITCH_STACK_SIZE($30)
319 ret $31,($1),1
320 .end undo_switch_stack
321
322 .align 3
323 .globl entUna
324 .ent entUna
325 entUna:
326 lda $30,-256($30)
327 stq $0,0($30)
328 ldq $0,256($30)
329 stq $1,8($30)
330 stq $2,16($30)
331 stq $3,24($30)
332 and $0,8,$0
333 stq $4,32($30)
334 bne $0,entUnaUser
335 stq $5,40($30)
336 stq $6,48($30)
337 stq $7,56($30)
338 stq $8,64($30)
339 stq $9,72($30)
340 stq $10,80($30)
341 stq $11,88($30)
342 stq $12,96($30)
343 stq $13,104($30)
344 stq $14,112($30)
345 stq $15,120($30)
346
347 stq $19,152($30)
348 stq $20,160($30)
349 stq $21,168($30)
350 stq $22,176($30)
351 stq $23,184($30)
352 stq $24,192($30)
353 stq $25,200($30)
354 stq $26,208($30)
355 stq $27,216($30)
356 stq $28,224($30)
357 stq $29,232($30)
358 stq $30,240($30)
359 stq $31,248($30)
360 lda $27,do_entUna
361 jsr $26,($27),do_entUna
362 ldq $0,0($30)
363 ldq $1,8($30)
364 ldq $2,16($30)
365 ldq $3,24($30)
366 ldq $4,32($30)
367 ldq $5,40($30)
368 ldq $6,48($30)
369 ldq $7,56($30)
370 ldq $8,64($30)
371 ldq $9,72($30)
372 ldq $10,80($30)
373 ldq $11,88($30)
374 ldq $12,96($30)
375 ldq $13,104($30)
376 ldq $14,112($30)
377 ldq $15,120($30)
378
379 ldq $19,152($30)
380 ldq $20,160($30)
381 ldq $21,168($30)
382 ldq $22,176($30)
383 ldq $23,184($30)
384 ldq $24,192($30)
385 ldq $25,200($30)
386 ldq $26,208($30)
387 ldq $27,216($30)
388 ldq $28,224($30)
389 ldq $29,232($30)
390 ldq $30,240($30)
391 lda $30,256($30)
392 rti
393 .end entUna
394
395 .align 3
396 .ent entUnaUser
397 entUnaUser:
398 ldq $0,0($30)
399 lda $30,256($30)
400 SAVE_ALL
401 lda $30,-56($30)
402 stq $9,0($30)
403 stq $10,8($30)
404 stq $11,16($30)
405 stq $12,24($30)
406 stq $13,32($30)
407 stq $14,40($30)
408 stq $15,48($30)
409 lda $27,do_entUnaUser
410 bis $31,$30,$19
411 jsr $26,($27),do_entUnaUser
412 ldq $9,0($30)
413 ldq $10,8($30)
414 ldq $11,16($30)
415 ldq $12,24($30)
416 ldq $13,32($30)
417 ldq $14,40($30)
418 ldq $15,48($30)
419 lda $30,56($30)
420 br $31,ret_from_sys_call
421
422 .end entUnaUser
423
424
425
426
427 .align 3
428 .globl sys_fork
429 .ent sys_fork
430 sys_fork:
431 br $1,do_switch_stack
432 bis $31,SIGCHLD,$16
433 bis $31,$31,$17
434 bis $30,$30,$18
435 lda $27,alpha_clone
436 jsr $26,($27),alpha_clone
437 br $1,undo_switch_stack
438 ret $31,($26),1
439 .end sys_fork
440
441 .align 3
442 .globl sys_clone
443 .ent sys_clone
444 sys_clone:
445 br $1,do_switch_stack
446
447 bis $30,$30,$18
448 lda $27,alpha_clone
449 jsr $26,($27),alpha_clone
450 br $1,undo_switch_stack
451 ret $31,($26),1
452 .end sys_clone
453
454 .align 3
455 .globl alpha_switch_to
456 .ent alpha_switch_to
457 alpha_switch_to:
458 br $1,do_switch_stack
459 call_pal PAL_swpctx
460 br $1,undo_switch_stack
461 ret $31,($26),1
462 .end alpha_switch_to
463
464
465
466
467
468
469
470
471 .align 3
472 .globl entSys
473 .globl ret_from_sys_call
474 .ent entSys
475 entSys:
476 stq $16,24($30)
477 stq $17,32($30)
478 stq $18,40($30)
479 SAVE_ALL
480 lda $1,NR_SYSCALLS($31)
481 lda $2,sys_call_table
482 lda $27,do_entSys
483 cmpult $0,$1,$1
484 s8addq $0,$2,$2
485 beq $1,1f
486 ldq $27,0($2)
487 1: jsr $26,($27),do_entSys
488 blt $0,syscall_error
489 stq $0,0($30)
490 stq $31,72($30)
491
492 .align 3
493 ret_from_sys_call:
494 cmovne $26,0,$19
495
496 lda $0,intr_count
497 ldq $1,0($0)
498 bne $1,ret_from_handle_bh
499 lda $2,bh_active
500 ldq $3,0($2)
501 lda $2,bh_mask
502 ldq $4,0($2)
503 addq $1,1,$1
504 and $3,$4,$2
505 bne $2,handle_bottom_half
506 ret_from_handle_bh:
507 ldq $0,SP_OFF($30)
508 and $0,8,$0
509 beq $0,restore_all
510 ret_from_reschedule:
511 lda $0,need_resched
512 lda $1,current_set
513 ldl $2,0($0)
514 lda $4,init_task
515 ldq $3,0($1)
516 bne $2,reschedule
517 subq $4,$3,$4
518 beq $4,restore_all
519 ldq $4,TASK_SIGNAL($3)
520 ldq $16,TASK_BLOCKED($3)
521 bic $4,$16,$4
522 bne $4,signal_return
523 restore_all:
524 RESTORE_ALL
525 rti
526
527 .align 3
528 handle_bottom_half:
529
530
531
532
533 stq $1,0($0)
534 subq $30,16,$30
535 stq $19,0($30)
536 stq $20,8($30)
537 lda $27,do_bottom_half
538 jsr $26,($27),do_bottom_half
539 lda $0,intr_count
540 ldq $19,0($30)
541 ldq $20,8($30)
542 addq $30,16,$30
543 stq $31,0($0)
544 br $31,ret_from_handle_bh
545
546 .align 3
547 syscall_error:
548
549
550
551
552
553
554
555 ldq $19,0($30)
556 beq $19,ret_success
557
558 ldq $20,72($30)
559 subq $31,$0,$0
560 addq $31,1,$1
561 bis $31,$31,$26
562 stq $1,72($30)
563 ret_success:
564 stq $0,0($30)
565 br $31,ret_from_sys_call
566
567 .align 3
568 signal_return:
569 bis $30,$30,$17
570 br $1,do_switch_stack
571 bis $30,$30,$18
572 lda $27,do_signal
573 jsr $26,($27),do_signal
574 lda $30,SWITCH_STACK_SIZE($30)
575 br $31,restore_all
576 .end entSys
577
578 .align 3
579 .ent reschedule
580 reschedule:
581 subq $30,16,$30
582 stq $19,0($30)
583 stq $20,8($30)
584 lda $27,schedule
585 jsr $26,($27),schedule
586 ldq $19,0($30)
587 ldq $20,8($30)
588 addq $30,16,$30
589 br $31,ret_from_reschedule
590 .end reschedule
591
592 .align 3
593 .ent sys_sigreturn
594 sys_sigreturn:
595 bis $30,$30,$17
596 lda $30,-SWITCH_STACK_SIZE($30)
597 bis $30,$30,$18
598 lda $27,do_sigreturn
599 jsr $26,($27),do_sigreturn
600 br $1,undo_switch_stack
601 br $31,ret_from_sys_call
602 .end sys_sigreturn
603
604 .align 3
605 .ent sys_sigsuspend
606 sys_sigsuspend:
607 bis $30,$30,$17
608 br $1,do_switch_stack
609 bis $30,$30,$18
610 lda $27,do_sigsuspend
611 jsr $26,($27),do_sigsuspend
612 lda $30,SWITCH_STACK_SIZE($30)
613 br $31,ret_from_sys_call
614 .end sys_sigsuspend
615
616 .align 3
617 .globl sys_call_table
618 sys_call_table:
619 .quad do_entSys, sys_exit, sys_fork, sys_read, sys_write
620 .quad do_entSys, sys_close, sys_wait4, do_entSys, sys_link
621 .quad sys_unlink, do_entSys, sys_chdir, sys_fchdir, sys_mknod
622 .quad sys_chmod, sys_chown, sys_brk, do_entSys, sys_lseek
623 .quad sys_getxpid, osf_mount, osf_umount, sys_setuid, sys_getxuid
624 .quad do_entSys, sys_ptrace, do_entSys, do_entSys, do_entSys
625 .quad do_entSys, do_entSys, do_entSys, sys_access, do_entSys
626 .quad do_entSys, sys_sync, sys_kill, do_entSys, sys_setpgid
627 .quad do_entSys, sys_dup, sys_pipe, do_entSys, do_entSys
628 .quad sys_open, do_entSys, sys_getxgid, osf_sigprocmask, do_entSys
629 .quad do_entSys, sys_acct, sys_sigpending, do_entSys, sys_ioctl
630 .quad do_entSys, do_entSys, sys_symlink, sys_readlink, sys_execve
631 .quad sys_umask, sys_chroot, do_entSys, sys_getpgrp, sys_getpagesize
632 .quad do_entSys, osf_vfork, sys_newstat, sys_newlstat, do_entSys
633 .quad do_entSys, osf_mmap, do_entSys, sys_munmap, sys_mprotect
634 .quad sys_madvise, sys_vhangup, do_entSys, do_entSys, sys_getgroups
635
636 .quad sys_setgroups, do_entSys, sys_setpgid, sys_setitimer, do_entSys
637 .quad do_entSys, sys_getitimer, sys_gethostname, sys_sethostname, sys_getdtablesize
638 .quad sys_dup2, sys_newfstat, sys_fcntl, sys_select, do_entSys
639 .quad sys_fsync, sys_setpriority, sys_socket, sys_connect, sys_accept
640 .quad osf_getpriority, sys_send, sys_recv, sys_sigreturn, sys_bind
641 .quad sys_setsockopt, sys_listen, do_entSys, do_entSys, do_entSys
642 .quad do_entSys, sys_sigsuspend, do_entSys, do_entSys, do_entSys
643 .quad do_entSys, sys_gettimeofday, sys_getrusage, sys_getsockopt, do_entSys
644 .quad sys_readv, sys_writev, sys_settimeofday, sys_fchown, sys_fchmod
645 .quad sys_recvfrom, sys_setreuid, sys_setregid, sys_rename, sys_truncate
646 .quad sys_ftruncate, sys_flock, sys_setgid, sys_sendto, sys_shutdown
647 .quad sys_socketpair, sys_mkdir, sys_rmdir, sys_utimes, do_entSys
648 .quad do_entSys, sys_getpeername, do_entSys, do_entSys, sys_getrlimit
649 .quad sys_setrlimit, do_entSys, sys_setsid, sys_quotactl, do_entSys
650 .quad sys_getsockname, do_entSys, do_entSys, do_entSys, do_entSys
651 .quad do_entSys, sys_sigaction, do_entSys, do_entSys, osf_getdirentries
652 .quad osf_statfs, osf_fstatfs, do_entSys, do_entSys, do_entSys
653 .quad osf_getdomainname, sys_setdomainname, do_entSys, do_entSys, do_entSys
654 .quad do_entSys, do_entSys, do_entSys, do_entSys, do_entSys
655 .quad do_entSys, do_entSys, do_entSys, do_entSys, do_entSys
656 .quad do_entSys, do_entSys, do_entSys, do_entSys, do_entSys
657 .quad do_entSys, do_entSys, do_entSys, do_entSys, do_entSys
658 .quad do_entSys, do_entSys, do_entSys, do_entSys, do_entSys
659 .quad do_entSys, do_entSys, do_entSys, do_entSys, osf_swapon
660 .quad sys_msgctl, sys_msgget, sys_msgrcv, sys_msgsnd, sys_semctl
661 .quad sys_semget, sys_semop, osf_utsname, do_entSys, osf_shmat
662 .quad sys_shmctl, sys_shmdt, sys_shmget, do_entSys, do_entSys
663 .quad do_entSys, do_entSys, sys_msync, do_entSys, do_entSys
664 .quad do_entSys, do_entSys, do_entSys, do_entSys, do_entSys
665 .quad do_entSys, do_entSys, do_entSys, do_entSys, do_entSys
666 .quad do_entSys, do_entSys, do_entSys, sys_getpgid, sys_getsid
667 .quad do_entSys, do_entSys, do_entSys, do_entSys, do_entSys
668 .quad do_entSys, do_entSys, do_entSys, do_entSys, osf_proplist_syscall
669 .quad do_entSys, do_entSys, do_entSys, do_entSys, do_entSys
670 .quad do_entSys, osf_usleep_thread, do_entSys, do_entSys, sys_sysfs
671 .quad do_entSys, osf_getsysinfo, osf_setsysinfo, do_entSys, do_entSys
672 .quad do_entSys, do_entSys, do_entSys, do_entSys, do_entSys
673 .quad do_entSys, do_entSys, do_entSys, do_entSys, do_entSys
674 .quad do_entSys, do_entSys, do_entSys, do_entSys, do_entSys
675 .quad do_entSys, do_entSys, do_entSys, do_entSys, do_entSys
676 .quad do_entSys, do_entSys, do_entSys, do_entSys, do_entSys
677 .quad do_entSys, do_entSys, do_entSys, do_entSys, do_entSys
678 .quad do_entSys, do_entSys, do_entSys, do_entSys, do_entSys
679 .quad do_entSys, do_entSys, do_entSys, do_entSys, do_entSys
680
681 .quad sys_bdflush, sys_sethae, sys_mount, sys_adjtimex, sys_swapoff
682 .quad sys_getdents, alpha_create_module, sys_init_module, sys_delete_module, sys_get_kernel_syms
683 .quad sys_syslog, sys_reboot, sys_clone, sys_uselib, sys_mlock
684 .quad sys_munlock, sys_mlockall, sys_munlockall, sys_sysinfo, sys_sysctl
685 .quad sys_idle, sys_umount, sys_swapon, sys_times, sys_personality
686 .quad sys_setfsuid, sys_setfsgid, sys_ustat, sys_statfs, sys_fstatfs
687 .quad sys_sched_setparam, sys_sched_getparam, sys_sched_setscheduler, sys_sched_getscheduler, sys_sched_yield
688 .quad sys_sched_get_priority_max, sys_sched_get_priority_min, sys_sched_rr_get_interval, do_entSys , sys_newuname
689 .quad do_entSys, do_entSys, do_entSys, do_entSys, do_entSys
690 .quad do_entSys, do_entSys, do_entSys, do_entSys, do_entSys