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