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 320
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 1: lda $0,intr_count
133 ldq $1,0($0)
134 subq $1,1,$1
135 bne $1,2f
136 lda $2,bh_active
137 ldq $3,0($2)
138 lda $2,bh_mask
139 ldq $2,0($2)
140 and $2,$3,$2
141 bne $2,3f
142 stq $1,0($0)
143 br $31,ret_from_sys_call
144 .align 3
145 2: stq $1,0($0)
146 br $31,restore_all
147 .align 3
148 3: lda $27,do_bottom_half
149 jsr $26,($27),do_bottom_half
150 br $31,1b
151 .end entInt
152
153 .align 3
154 .globl entMM
155 .ent entMM
156 entMM:
157 SAVE_ALL
158 lda $27,do_page_fault
159 lda $26,ret_from_sys_call
160 jsr $31,($27),do_page_fault
161 .end entMM
162
163 .align 3
164 .globl entArith
165 .ent entArith
166 entArith:
167 SAVE_ALL
168 lda $27,do_entArith
169 lda $26,ret_from_sys_call
170 jsr $31,($27),do_entArith
171 .end entArith
172
173 .align 3
174 .globl entIF
175 .ent entIF
176 entIF:
177 SAVE_ALL
178 lda $27,do_entIF
179 lda $26,ret_from_sys_call
180 jsr $31,($27),do_entIF
181 .end entIF
182
183
184
185
186
187
188
189
190
191
192 .align 3
193 .ent kernel_clone
194 kernel_clone:
195 subq $30,6*8,$30
196 stq $31,0($30)
197 stq $26,8($30)
198 stq $29,16($30)
199 stq $16,24($30)
200 stq $17,32($30)
201 stq $18,40($30)
202 bis $31,2,$0
203 SAVE_ALL
204 lda $27,sys_clone
205 jsr $26,($27),sys_clone
206 stq $0,0($30)
207 br ret_from_sys_call
208 .end kernel_clone
209
210
211
212
213 .align 3
214 .globl __kernel_thread
215 .ent __kernel_thread
216 __kernel_thread:
217 subq $30,4*8,$30
218 stq $9,0($30)
219 stq $10,8($30)
220 stq $26,16($30)
221 bis $17,$17,$9
222 bis $18,$18,$10
223 bsr $26,kernel_clone
224 bne $20,1f
225 ldq $9,0($30)
226 ldq $10,8($30)
227 ldq $26,16($30)
228 addq $30,4*8,$30
229 ret $31,($26),1
230
231 1: bis $9,$9,$27
232 bis $10,$10,$16
233 jsr $26,($27)
234 bis $0,$0,$16
235 lda $27,sys_exit
236 jsr $26,($27),sys_exit
237 call_pal PAL_halt
238 .end __kernel_thread
239
240 .align 3
241 .ent do_switch_stack
242 do_switch_stack:
243 lda $30,-SWITCH_STACK_SIZE($30)
244 stq $9,0($30)
245 stq $10,8($30)
246 stq $11,16($30)
247 stq $12,24($30)
248 stq $13,32($30)
249 stq $14,40($30)
250 stq $15,48($30)
251 stq $26,56($30)
252 stt $f0,64($30)
253 stt $f1,72($30)
254 stt $f2,80($30)
255 stt $f3,88($30)
256 stt $f4,96($30)
257 stt $f5,104($30)
258 stt $f6,112($30)
259 stt $f7,120($30)
260 stt $f8,128($30)
261 stt $f9,136($30)
262 stt $f10,144($30)
263 stt $f11,152($30)
264 stt $f12,160($30)
265 stt $f13,168($30)
266 stt $f14,176($30)
267 stt $f15,184($30)
268 stt $f16,192($30)
269 stt $f17,200($30)
270 stt $f18,208($30)
271 stt $f19,216($30)
272 stt $f20,224($30)
273 stt $f21,232($30)
274 stt $f22,240($30)
275 stt $f23,248($30)
276 stt $f24,256($30)
277 stt $f25,264($30)
278 stt $f26,272($30)
279 stt $f27,280($30)
280 stt $f28,288($30)
281 stt $f29,296($30)
282 stt $f30,304($30)
283 ret $31,($1),1
284 .end do_switch_stack
285
286 .align 3
287 .ent undo_switch_stack
288 undo_switch_stack:
289 ldq $9,0($30)
290 ldq $10,8($30)
291 ldq $11,16($30)
292 ldq $12,24($30)
293 ldq $13,32($30)
294 ldq $14,40($30)
295 ldq $15,48($30)
296 ldq $26,56($30)
297 ldt $f0,64($30)
298 ldt $f1,72($30)
299 ldt $f2,80($30)
300 ldt $f3,88($30)
301 ldt $f4,96($30)
302 ldt $f5,104($30)
303 ldt $f6,112($30)
304 ldt $f7,120($30)
305 ldt $f8,128($30)
306 ldt $f9,136($30)
307 ldt $f10,144($30)
308 ldt $f11,152($30)
309 ldt $f12,160($30)
310 ldt $f13,168($30)
311 ldt $f14,176($30)
312 ldt $f15,184($30)
313 ldt $f16,192($30)
314 ldt $f17,200($30)
315 ldt $f18,208($30)
316 ldt $f19,216($30)
317 ldt $f20,224($30)
318 ldt $f21,232($30)
319 ldt $f22,240($30)
320 ldt $f23,248($30)
321 ldt $f24,256($30)
322 ldt $f25,264($30)
323 ldt $f26,272($30)
324 ldt $f27,280($30)
325 ldt $f28,288($30)
326 ldt $f29,296($30)
327 ldt $f30,304($30)
328 lda $30,SWITCH_STACK_SIZE($30)
329 ret $31,($1),1
330 .end undo_switch_stack
331
332 .align 3
333 .globl entUna
334 .ent entUna
335 entUna:
336 lda $30,-256($30)
337 stq $0,0($30)
338 ldq $0,256($30)
339 stq $1,8($30)
340 stq $2,16($30)
341 stq $3,24($30)
342 and $0,8,$0
343 stq $4,32($30)
344 bne $0,entUnaUser
345 stq $5,40($30)
346 stq $6,48($30)
347 stq $7,56($30)
348 stq $8,64($30)
349 stq $9,72($30)
350 stq $10,80($30)
351 stq $11,88($30)
352 stq $12,96($30)
353 stq $13,104($30)
354 stq $14,112($30)
355 stq $15,120($30)
356
357 stq $19,152($30)
358 stq $20,160($30)
359 stq $21,168($30)
360 stq $22,176($30)
361 stq $23,184($30)
362 stq $24,192($30)
363 stq $25,200($30)
364 stq $26,208($30)
365 stq $27,216($30)
366 stq $28,224($30)
367 stq $29,232($30)
368 stq $30,240($30)
369 stq $31,248($30)
370 lda $27,do_entUna
371 jsr $26,($27),do_entUna
372 ldq $0,0($30)
373 ldq $1,8($30)
374 ldq $2,16($30)
375 ldq $3,24($30)
376 ldq $4,32($30)
377 ldq $5,40($30)
378 ldq $6,48($30)
379 ldq $7,56($30)
380 ldq $8,64($30)
381 ldq $9,72($30)
382 ldq $10,80($30)
383 ldq $11,88($30)
384 ldq $12,96($30)
385 ldq $13,104($30)
386 ldq $14,112($30)
387 ldq $15,120($30)
388
389 ldq $19,152($30)
390 ldq $20,160($30)
391 ldq $21,168($30)
392 ldq $22,176($30)
393 ldq $23,184($30)
394 ldq $24,192($30)
395 ldq $25,200($30)
396 ldq $26,208($30)
397 ldq $27,216($30)
398 ldq $28,224($30)
399 ldq $29,232($30)
400 ldq $30,240($30)
401 lda $30,256($30)
402 rti
403 .end entUna
404
405 .align 3
406 .ent entUnaUser
407 entUnaUser:
408 ldq $0,0($30)
409 lda $30,256($30)
410 SAVE_ALL
411 lda $30,-56($30)
412 stq $9,0($30)
413 stq $10,8($30)
414 stq $11,16($30)
415 stq $12,24($30)
416 stq $13,32($30)
417 stq $14,40($30)
418 stq $15,48($30)
419 lda $27,do_entUnaUser
420 bis $31,$30,$19
421 jsr $26,($27),do_entUnaUser
422 ldq $9,0($30)
423 ldq $10,8($30)
424 ldq $11,16($30)
425 ldq $12,24($30)
426 ldq $13,32($30)
427 ldq $14,40($30)
428 ldq $15,48($30)
429 lda $30,56($30)
430 br $31,ret_from_sys_call
431
432 .end entUnaUser
433
434
435
436
437 .align 3
438 .globl sys_fork
439 .ent sys_fork
440 sys_fork:
441 br $1,do_switch_stack
442 bis $31,SIGCHLD,$16
443 bis $31,$31,$17
444 bis $30,$30,$18
445 lda $27,alpha_clone
446 jsr $26,($27),alpha_clone
447 br $1,undo_switch_stack
448 ret $31,($26),1
449 .end sys_fork
450
451 .align 3
452 .globl sys_clone
453 .ent sys_clone
454 sys_clone:
455 br $1,do_switch_stack
456
457 bis $30,$30,$18
458 lda $27,alpha_clone
459 jsr $26,($27),alpha_clone
460 br $1,undo_switch_stack
461 ret $31,($26),1
462 .end sys_clone
463
464 .align 3
465 .globl alpha_switch_to
466 .ent alpha_switch_to
467 alpha_switch_to:
468 br $1,do_switch_stack
469 call_pal PAL_swpctx
470 br $1,undo_switch_stack
471 ret $31,($26),1
472 .end alpha_switch_to
473
474
475
476
477
478
479
480
481 .align 3
482 .globl entSys
483 .globl ret_from_sys_call
484 .ent entSys
485 entSys:
486 stq $16,24($30)
487 stq $17,32($30)
488 stq $18,40($30)
489 SAVE_ALL
490 lda $1,NR_SYSCALLS($31)
491 lda $2,sys_call_table
492 lda $27,do_entSys
493 cmpult $0,$1,$1
494 s8addq $0,$2,$2
495 beq $1,1f
496 ldq $27,0($2)
497 1: jsr $26,($27),do_entSys
498 blt $0,syscall_error
499 stq $0,0($30)
500 stq $31,72($30)
501 .align 3
502 ret_from_sys_call:
503 ldq $0,SP_OFF($30)
504 cmovne $26,0,$19
505 and $0,8,$0
506 beq $0,restore_all
507 ret_from_reschedule:
508 lda $0,need_resched
509 lda $1,current_set
510 ldl $2,0($0)
511 lda $4,init_task
512 ldq $3,0($1)
513 bne $2,reschedule
514 subq $4,$3,$4
515 beq $4,restore_all
516 ldq $4,TASK_SIGNAL($3)
517 ldq $16,TASK_BLOCKED($3)
518 bic $4,$16,$4
519 bne $4,signal_return
520 restore_all:
521 RESTORE_ALL
522 rti
523
524 .align 3
525 syscall_error:
526
527
528
529
530
531
532
533 ldq $19,0($30)
534 beq $19,ret_success
535
536 ldq $20,72($30)
537 subq $31,$0,$0
538 addq $31,1,$1
539 bis $31,$31,$26
540 stq $1,72($30)
541 ret_success:
542 stq $0,0($30)
543 br $31,ret_from_sys_call
544
545 .align 3
546 signal_return:
547 bis $30,$30,$17
548 br $1,do_switch_stack
549 bis $30,$30,$18
550 lda $27,do_signal
551 jsr $26,($27),do_signal
552 lda $30,SWITCH_STACK_SIZE($30)
553 br $31,restore_all
554 .end entSys
555
556 .align 3
557 .ent reschedule
558 reschedule:
559 subq $30,16,$30
560 stq $19,0($30)
561 stq $20,8($30)
562 lda $27,schedule
563 jsr $26,($27),schedule
564 ldq $19,0($30)
565 ldq $20,8($30)
566 addq $30,16,$30
567 br $31,ret_from_reschedule
568 .end reschedule
569
570 .align 3
571 .ent sys_sigreturn
572 sys_sigreturn:
573 bis $30,$30,$17
574 lda $30,-SWITCH_STACK_SIZE($30)
575 bis $30,$30,$18
576 lda $27,do_sigreturn
577 jsr $26,($27),do_sigreturn
578 br $1,undo_switch_stack
579 br $31,ret_from_sys_call
580 .end sys_sigreturn
581
582 .align 3
583 .ent sys_sigsuspend
584 sys_sigsuspend:
585 bis $30,$30,$17
586 br $1,do_switch_stack
587 bis $30,$30,$18
588 lda $27,do_sigsuspend
589 jsr $26,($27),do_sigsuspend
590 lda $30,SWITCH_STACK_SIZE($30)
591 br $31,ret_from_sys_call
592 .end sys_sigsuspend
593
594 .align 3
595 .globl sys_call_table
596 sys_call_table:
597 .quad do_entSys, sys_exit, sys_fork, sys_read, sys_write
598 .quad do_entSys, sys_close, sys_wait4, do_entSys, sys_link
599 .quad sys_unlink, do_entSys, sys_chdir, sys_fchdir, sys_mknod
600 .quad sys_chmod, sys_chown, sys_brk, do_entSys, sys_lseek
601 .quad sys_getxpid, osf_mount, osf_umount, sys_setuid, sys_getxuid
602 .quad do_entSys, sys_ptrace, do_entSys, do_entSys, do_entSys
603 .quad do_entSys, do_entSys, do_entSys, sys_access, do_entSys
604 .quad do_entSys, sys_sync, sys_kill, do_entSys, sys_setpgid
605 .quad do_entSys, sys_dup, sys_pipe, do_entSys, do_entSys
606 .quad sys_open, do_entSys, sys_getxgid, osf_sigprocmask, do_entSys
607 .quad do_entSys, sys_acct, do_entSys, do_entSys, sys_ioctl
608 .quad do_entSys, do_entSys, sys_symlink, sys_readlink, sys_execve
609 .quad sys_umask, sys_chroot, do_entSys, sys_getpgrp, sys_getpagesize
610 .quad do_entSys, osf_vfork, sys_newstat, sys_newlstat, do_entSys
611 .quad do_entSys, osf_mmap, do_entSys, sys_munmap, sys_mprotect
612 .quad sys_madvise, sys_vhangup, do_entSys, do_entSys, sys_getgroups
613
614 .quad sys_setgroups, do_entSys, sys_setpgid, sys_setitimer, do_entSys
615 .quad do_entSys, sys_getitimer, sys_gethostname, sys_sethostname, sys_getdtablesize
616 .quad sys_dup2, sys_newfstat, sys_fcntl, sys_select, do_entSys
617 .quad sys_fsync, sys_setpriority, sys_socket, sys_connect, sys_accept
618 .quad sys_getpriority, sys_send, sys_recv, sys_sigreturn, sys_bind
619 .quad sys_setsockopt, sys_listen, do_entSys, do_entSys, do_entSys
620 .quad do_entSys, sys_sigsuspend, do_entSys, do_entSys, do_entSys
621 .quad do_entSys, sys_gettimeofday, sys_getrusage, sys_getsockopt, do_entSys
622 .quad sys_readv, sys_writev, sys_settimeofday, sys_fchown, sys_fchmod
623 .quad sys_recvfrom, sys_setreuid, sys_setregid, sys_rename, sys_truncate
624 .quad sys_ftruncate, do_entSys, sys_setgid, sys_sendto, sys_shutdown
625 .quad sys_socketpair, sys_mkdir, sys_rmdir, sys_utimes, do_entSys
626 .quad do_entSys, sys_getpeername, do_entSys, do_entSys, sys_getrlimit
627 .quad sys_setrlimit, do_entSys, sys_setsid, do_entSys, do_entSys
628 .quad sys_getsockname, do_entSys, do_entSys, do_entSys, do_entSys
629 .quad do_entSys, sys_sigaction, do_entSys, do_entSys, osf_getdirentries
630 .quad osf_statfs, osf_fstatfs, do_entSys, do_entSys, do_entSys
631 .quad osf_getdomainname, do_entSys, do_entSys, do_entSys, do_entSys
632 .quad do_entSys, do_entSys, do_entSys, do_entSys, do_entSys
633 .quad do_entSys, do_entSys, do_entSys, do_entSys, do_entSys
634 .quad do_entSys, do_entSys, do_entSys, do_entSys, do_entSys
635 .quad do_entSys, do_entSys, do_entSys, do_entSys, do_entSys
636 .quad do_entSys, do_entSys, do_entSys, do_entSys, do_entSys
637 .quad do_entSys, do_entSys, do_entSys, do_entSys, osf_swapon
638 .quad sys_msgctl, sys_msgget, sys_msgrcv, sys_msgsnd, sys_semctl
639 .quad sys_semget, sys_semop, osf_utsname, do_entSys, osf_shmat
640 .quad sys_shmctl, sys_shmdt, sys_shmget, do_entSys, do_entSys
641 .quad do_entSys, do_entSys, do_entSys, do_entSys, do_entSys
642 .quad do_entSys, do_entSys, do_entSys, do_entSys, do_entSys
643 .quad do_entSys, do_entSys, do_entSys, do_entSys, do_entSys
644 .quad do_entSys, do_entSys, do_entSys, do_entSys, do_entSys
645 .quad do_entSys, do_entSys, do_entSys, do_entSys, do_entSys
646 .quad do_entSys, do_entSys, do_entSys, do_entSys, osf_proplist_syscall
647 .quad do_entSys, do_entSys, do_entSys, do_entSys, do_entSys
648 .quad do_entSys, osf_usleep_thread, do_entSys, do_entSys, do_entSys
649 .quad do_entSys, do_entSys, do_entSys, do_entSys, do_entSys
650 .quad do_entSys, do_entSys, do_entSys, do_entSys, do_entSys
651 .quad do_entSys, do_entSys, do_entSys, do_entSys, do_entSys
652 .quad do_entSys, do_entSys, do_entSys, do_entSys, do_entSys
653 .quad do_entSys, do_entSys, 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
659 .quad sys_bdflush, sys_sethae, sys_mount, sys_adjtimex, sys_swapoff
660 .quad sys_getdents, sys_create_module, sys_init_module, sys_delete_module, sys_get_kernel_syms
661 .quad sys_syslog, sys_reboot, sys_clone, sys_uselib, do_entSys
662 .quad do_entSys, do_entSys, do_entSys, do_entSys, do_entSys
663