OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rc203soc/] [sw/] [uClinux/] [arch/] [alpha/] [kernel/] [entry.S] - Blame information for rev 1622

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1622 jcastillo
/*
2
 * alpha/entry.S
3
 *
4
 * kernel entry-points
5
 */
6
 
7
#include 
8
#include 
9
 
10
#define halt    .long PAL_halt
11
#define rti     .long PAL_rti
12
#define SIGCHLD 20
13
 
14
#define NR_SYSCALLS 350
15
#define osf_vfork sys_fork
16
 
17
/*
18
 * These offsets must match with "struct hae" in io.h:
19
 */
20
#define HAE_CACHE       0
21
#define HAE_REG         8
22
 
23
/*
24
 * stack offsets
25
 */
26
#define SP_OFF          184
27
 
28
#define SWITCH_STACK_SIZE 320
29
 
30
/*
31
 * task structure offsets
32
 */
33
#define TASK_STATE      0
34
#define TASK_COUNTER    8
35
#define TASK_PRIORITY   16
36
#define TASK_SIGNAL     24
37
#define TASK_BLOCKED    32
38
#define TASK_FLAGS      40
39
 
40
/*
41
 * task flags (must match include/linux/sched.h):
42
 */
43
#define PF_PTRACED      0x00000010
44
 
45
/*
46
 * This defines the normal kernel pt-regs layout.
47
 *
48
 * regs 9-15 preserved by C code
49
 * regs 16-18 saved by PAL-code
50
 * regs 29-30 saved and set up by PAL-code
51
 * JRP - Save regs 16-18 in a special area of the stack, so that
52
 * the palcode-provided values are available to the signal handler.
53
 */
54
#define SAVE_ALL                        \
55
        subq    $30,184,$30;            \
56
        stq     $0,0($30);              \
57
        stq     $1,8($30);              \
58
        stq     $2,16($30);             \
59
        stq     $3,24($30);             \
60
        stq     $4,32($30);             \
61
        stq     $5,40($30);             \
62
        stq     $6,48($30);             \
63
        stq     $7,56($30);             \
64
        stq     $8,64($30);             \
65
        stq     $19,72($30);            \
66
        stq     $20,80($30);            \
67
        stq     $21,88($30);            \
68
        stq     $22,96($30);            \
69
        stq     $23,104($30);           \
70
        stq     $24,112($30);           \
71
        stq     $25,120($30);           \
72
        stq     $26,128($30);           \
73
        stq     $27,136($30);           \
74
        stq     $28,144($30);           \
75
        lda     $2,hae;                 \
76
        ldq     $2,HAE_CACHE($2);       \
77
        stq     $2,152($30);            \
78
        stq     $16,160($30);           \
79
        stq     $17,168($30);           \
80
        stq     $18,176($30)
81
 
82
#define RESTORE_ALL                     \
83
        lda     $8,hae;                 \
84
        ldq     $7,HAE_CACHE($8);       \
85
        ldq     $6,152($30);            \
86
        subq    $7,$6,$5;               \
87
        beq     $5,99f;                 \
88
        ldq     $7,HAE_REG($8);         \
89
        addq    $31,7,$16;              \
90
        call_pal PAL_swpipl;            \
91
        stq     $6,HAE_CACHE($8);       \
92
        stq     $6,0($7);               \
93
        mb;                             \
94
        bis     $0,$0,$16;              \
95
        call_pal PAL_swpipl;            \
96
99:;                                    \
97
        ldq     $0,0($30);              \
98
        ldq     $1,8($30);              \
99
        ldq     $2,16($30);             \
100
        ldq     $3,24($30);             \
101
        ldq     $4,32($30);             \
102
        ldq     $5,40($30);             \
103
        ldq     $6,48($30);             \
104
        ldq     $7,56($30);             \
105
        ldq     $8,64($30);             \
106
        ldq     $19,72($30);            \
107
        ldq     $20,80($30);            \
108
        ldq     $21,88($30);            \
109
        ldq     $22,96($30);            \
110
        ldq     $23,104($30);           \
111
        ldq     $24,112($30);           \
112
        ldq     $25,120($30);           \
113
        ldq     $26,128($30);           \
114
        ldq     $27,136($30);           \
115
        ldq     $28,144($30);           \
116
        addq    $30,184,$30
117
 
118
.text
119
.set noat
120
#if defined(__linux__) && !defined(__ELF__)
121
  .set singlegp
122
#endif
123
 
124
.align 3
125
.globl  entInt
126
.ent    entInt
127
entInt:
128
        SAVE_ALL
129
/* start atomic operation with respect to software interrupts */
130
        lda     $0,intr_count
131
        ldq     $1,0($0)
132
        addq    $1,1,$1
133
        stq     $1,0($0)
134
/* set up the arguments to the C interrupt handler */
135
        lda     $27,do_entInt
136
        jsr     $26,($27),do_entInt
137
/* ok, return */
138
        lda     $0,intr_count
139
        ldq     $1,0($0)
140
        subq    $1,1,$1
141
        stq     $1,0($0)
142
        br      $31,ret_from_sys_call
143
.end entInt
144
 
145
.align 3
146
.globl  entMM
147
.ent    entMM
148
entMM:
149
        SAVE_ALL
150
        lda     $27,do_page_fault
151
        lda     $26,ret_from_sys_call
152
        jsr     $31,($27),do_page_fault
153
.end entMM
154
 
155
.align 3
156
.globl  entArith
157
.ent    entArith
158
entArith:
159
        SAVE_ALL
160
        lda     $27,do_entArith
161
        lda     $26,ret_from_sys_call
162
        jsr     $31,($27),do_entArith
163
.end entArith
164
 
165
.align 3
166
.globl  entIF
167
.ent    entIF
168
entIF:
169
#ifdef CONFIG_KGDB
170
        bne     $16,1f          /* not a bpt trap -> */
171
        /*
172
         * Call kgdb if it's enabled and if "current" is not being
173
         * traced or if we get a bpt in kernel mode (the architecture
174
         * manual defines the values of $17 and $18 as "unpredictable",
175
         * so they are fair game).
176
         */
177
        lda     $17,kgdb_enabled
178
        ldl     $17,0($17)
179
        beq     $17,1f          /* kgdb not enabled -> */
180
 
181
#ifndef CONFIG_ALPHA_CABRIOLET
182
        /*
183
         * MILO on Cabriolet doesn't seem to setup the PS in the
184
         * PALframe correctly. (davidm@azstarnet.com)
185
         */
186
        ldq     $18,0($30)      /* get ps */
187
        and     $18,8,$18
188
        beq     $18,entKGDB
189
#endif
190
 
191
        lda     $17,current_set
192
        ldq     $17,0($17)
193
        bis     $31,PF_PTRACED,$18
194
        ldq     $17,TASK_FLAGS($17)
195
        and     $17,$18,$17
196
        beq     $17,entKGDB
197
1:
198
#endif
199
        SAVE_ALL
200
        lda     $27,do_entIF
201
        lda     $26,ret_from_sys_call
202
        jsr     $31,($27),do_entIF
203
.end entIF
204
 
205
/*
206
 * Fork() is one of the special system calls: it needs to
207
 * save the callee-saved regs so that the regs can be found
208
 * for the new process.. We save them in the "context switch"
209
 * stack format (see arch/alpha/kernel/process.c).
210
 *
211
 * Also, for the kernel fork, we need to fake the system call
212
 * stack buildup, as we can't do system calls from kernel space.
213
 */
214
.align 3
215
.ent    kernel_clone
216
kernel_clone:
217
        subq $30,6*8,$30
218
        stq $31,0($30)
219
        stq $26,8($30)
220
        stq $29,16($30)
221
        stq $16,24($30)
222
        stq $17,32($30)
223
        stq $18,40($30)
224
        bis $31,2,$0    /* Register v0: syscall nr for fork() */
225
        SAVE_ALL
226
        lda $27,sys_clone
227
        jsr $26,($27),sys_clone
228
        stq $0,0($30)
229
        br $31,ret_from_sys_call
230
.end    kernel_clone
231
 
232
/*
233
 * __kernel_thread(clone_flags, fn, arg)
234
 */
235
.align 3
236
.globl  __kernel_thread
237
.ent    __kernel_thread
238
__kernel_thread:
239
        subq $30,4*8,$30
240
        stq $9,0($30)
241
        stq $10,8($30)
242
        stq $26,16($30)
243
        bis $17,$17,$9          /* save fn */
244
        bis $18,$18,$10         /* save arg */
245
        bsr $26,kernel_clone
246
        bne $20,1f              /* $20 is non-zero in child */
247
        ldq $9,0($30)
248
        ldq $10,8($30)
249
        ldq $26,16($30)
250
        addq $30,4*8,$30
251
        ret $31,($26),1
252
/* this is in child: look out as we don't have any stack here.. */
253
1:      bis $9,$9,$27           /* get fn */
254
        bis $10,$10,$16         /* get arg */
255
        jsr $26,($27)
256
        bis $0,$0,$16
257
        lda $27,sys_exit
258
        jsr $26,($27),sys_exit
259
        call_pal PAL_halt
260
.end    __kernel_thread
261
 
262
.align 3
263
.ent    do_switch_stack
264
do_switch_stack:
265
        lda $30,-SWITCH_STACK_SIZE($30)
266
        stq  $9,0($30)
267
        stq $10,8($30)
268
        stq $11,16($30)
269
        stq $12,24($30)
270
        stq $13,32($30)
271
        stq $14,40($30)
272
        stq $15,48($30)
273
        stq $26,56($30)
274
        stt $f0,64($30)
275
        stt $f1,72($30)
276
        stt $f2,80($30)
277
        stt $f3,88($30)
278
        stt $f4,96($30)
279
        stt $f5,104($30)
280
        stt $f6,112($30)
281
        stt $f7,120($30)
282
        stt $f8,128($30)
283
        stt $f9,136($30)
284
        stt $f10,144($30)
285
        stt $f11,152($30)
286
        stt $f12,160($30)
287
        stt $f13,168($30)
288
        stt $f14,176($30)
289
        stt $f15,184($30)
290
        stt $f16,192($30)
291
        stt $f17,200($30)
292
        stt $f18,208($30)
293
        stt $f19,216($30)
294
        stt $f20,224($30)
295
        stt $f21,232($30)
296
        stt $f22,240($30)
297
        stt $f23,248($30)
298
        stt $f24,256($30)
299
        stt $f25,264($30)
300
        stt $f26,272($30)
301
        stt $f27,280($30)
302
        mf_fpcr $f0             # get fpcr
303
        stt $f28,288($30)
304
        stt $f29,296($30)
305
        stt $f30,304($30)
306
        stt $f0,312($30)        # save fpcr in slot of $f31
307
        ret $31,($1),1
308
.end do_switch_stack
309
 
310
.align 3
311
.ent    undo_switch_stack
312
undo_switch_stack:
313
        ldq  $9,0($30)
314
        ldq $10,8($30)
315
        ldq $11,16($30)
316
        ldq $12,24($30)
317
        ldq $13,32($30)
318
        ldq $14,40($30)
319
        ldq $15,48($30)
320
        ldq $26,56($30)
321
        ldt $f30,312($30)       # get saved fpcr
322
        ldt $f0,64($30)
323
        ldt $f1,72($30)
324
        ldt $f2,80($30)
325
        ldt $f3,88($30)
326
        mt_fpcr $f30            # install saved fpcr
327
        ldt $f4,96($30)
328
        ldt $f5,104($30)
329
        ldt $f6,112($30)
330
        ldt $f7,120($30)
331
        ldt $f8,128($30)
332
        ldt $f9,136($30)
333
        ldt $f10,144($30)
334
        ldt $f11,152($30)
335
        ldt $f12,160($30)
336
        ldt $f13,168($30)
337
        ldt $f14,176($30)
338
        ldt $f15,184($30)
339
        ldt $f16,192($30)
340
        ldt $f17,200($30)
341
        ldt $f18,208($30)
342
        ldt $f19,216($30)
343
        ldt $f20,224($30)
344
        ldt $f21,232($30)
345
        ldt $f22,240($30)
346
        ldt $f23,248($30)
347
        ldt $f24,256($30)
348
        ldt $f25,264($30)
349
        ldt $f26,272($30)
350
        ldt $f27,280($30)
351
        ldt $f28,288($30)
352
        ldt $f29,296($30)
353
        ldt $f30,304($30)
354
        lda $30,SWITCH_STACK_SIZE($30)
355
        ret $31,($1),1
356
.end undo_switch_stack
357
 
358
.align 3
359
.globl  entUna
360
.ent    entUna
361
entUna:
362
        lda $30,-256($30)
363
        stq $0,0($30)
364
        ldq $0,256($30)         /* get PS */
365
        stq $1,8($30)
366
        stq $2,16($30)
367
        stq $3,24($30)
368
        and $0,8,$0             /* user mode? */
369
        stq $4,32($30)
370
        bne $0,entUnaUser       /* yup -> do user-level unaligned fault */
371
        stq $5,40($30)
372
        stq $6,48($30)
373
        stq $7,56($30)
374
        stq $8,64($30)
375
        stq $9,72($30)
376
        stq $10,80($30)
377
        stq $11,88($30)
378
        stq $12,96($30)
379
        stq $13,104($30)
380
        stq $14,112($30)
381
        stq $15,120($30)
382
        /* 16-18 PAL-saved */
383
        stq $19,152($30)
384
        stq $20,160($30)
385
        stq $21,168($30)
386
        stq $22,176($30)
387
        stq $23,184($30)
388
        stq $24,192($30)
389
        stq $25,200($30)
390
        stq $26,208($30)
391
        stq $27,216($30)
392
        stq $28,224($30)
393
        stq $29,232($30)
394
        stq $30,240($30)
395
        stq $31,248($30)
396
        lda $27,do_entUna
397
        jsr $26,($27),do_entUna
398
        ldq $0,0($30)
399
        ldq $1,8($30)
400
        ldq $2,16($30)
401
        ldq $3,24($30)
402
        ldq $4,32($30)
403
        ldq $5,40($30)
404
        ldq $6,48($30)
405
        ldq $7,56($30)
406
        ldq $8,64($30)
407
        ldq $9,72($30)
408
        ldq $10,80($30)
409
        ldq $11,88($30)
410
        ldq $12,96($30)
411
        ldq $13,104($30)
412
        ldq $14,112($30)
413
        ldq $15,120($30)
414
        /* 16-18 PAL-saved */
415
        ldq $19,152($30)
416
        ldq $20,160($30)
417
        ldq $21,168($30)
418
        ldq $22,176($30)
419
        ldq $23,184($30)
420
        ldq $24,192($30)
421
        ldq $25,200($30)
422
        ldq $26,208($30)
423
        ldq $27,216($30)
424
        ldq $28,224($30)
425
        ldq $29,232($30)
426
        ldq $30,240($30)
427
        lda $30,256($30)
428
        rti
429
.end entUna
430
 
431
.align 3
432
.ent    entUnaUser
433
entUnaUser:
434
        ldq $0,0($30)                   /* restore original $0 */
435
        lda $30,256($30)                /* pop entUna's stack frame */
436
        SAVE_ALL                        /* setup normal kernel stack */
437
        lda $30,-56($30)
438
        stq $9,0($30)
439
        stq $10,8($30)
440
        stq $11,16($30)
441
        stq $12,24($30)
442
        stq $13,32($30)
443
        stq $14,40($30)
444
        stq $15,48($30)
445
        lda $27,do_entUnaUser
446
        bis $31,$30,$19
447
        jsr $26,($27),do_entUnaUser
448
        ldq $9,0($30)
449
        ldq $10,8($30)
450
        ldq $11,16($30)
451
        ldq $12,24($30)
452
        ldq $13,32($30)
453
        ldq $14,40($30)
454
        ldq $15,48($30)
455
        lda $30,56($30)
456
        br $31,ret_from_sys_call
457
 
458
.end    entUnaUser
459
 
460
/*
461
 * A fork is the same as clone(SIGCHLD, 0);
462
*/
463
.align 3
464
.globl  sys_fork
465
.ent    sys_fork
466
sys_fork:
467
        bsr $1,do_switch_stack
468
        bis $31,SIGCHLD,$16
469
        bis $31,$31,$17
470
        bis $30,$30,$18
471
        lda $27,alpha_clone
472
        jsr $26,($27),alpha_clone
473
        bsr $1,undo_switch_stack
474
        ret $31,($26),1
475
.end    sys_fork
476
 
477
.align 3
478
.globl  sys_clone
479
.ent    sys_clone
480
sys_clone:
481
        bsr $1,do_switch_stack
482
        /* arg1 and arg2 come from the user */
483
        bis $30,$30,$18
484
        lda $27,alpha_clone
485
        jsr $26,($27),alpha_clone
486
        bsr $1,undo_switch_stack
487
        ret $31,($26),1
488
.end    sys_clone
489
 
490
.align 3
491
.globl  alpha_switch_to
492
.ent    alpha_switch_to
493
alpha_switch_to:
494
        bsr $1,do_switch_stack
495
        call_pal PAL_swpctx
496
        bsr $1,undo_switch_stack
497
        ret $31,($26),1
498
.end alpha_switch_to
499
 
500
/*
501
 * Oh, well.. Disassembling OSF/1 binaries to find out how the
502
 * system calls work isn't much fun.
503
 *
504
 * entSys is special in that the PAL-code doesn't save a0-a2, so
505
 * we start off by doing that by hand.
506
 */
507
.align 3
508
.globl  entSys
509
.globl  ret_from_sys_call
510
.ent    entSys
511
entSys:
512
        stq     $16,24($30)
513
        stq     $17,32($30)
514
        stq     $18,40($30)
515
        SAVE_ALL
516
        /* FIXME: optimize */
517
        lda     $1,current_set
518
        ldq     $2,0($1)
519
        ldq     $3,TASK_FLAGS($2)
520
        and     $3,PF_PTRACED,$3
521
        bne     $3,strace
522
        /* end of strace */
523
        lda     $1,NR_SYSCALLS($31)
524
        lda     $2,sys_call_table
525
        lda     $27,do_entSys
526
        cmpult  $0,$1,$1
527
        s8addq  $0,$2,$2
528
        beq     $1,1f
529
        ldq     $27,0($2)
530
1:      jsr     $26,($27),do_entSys
531
        blt     $0,syscall_error        /* the call failed */
532
        stq     $0,0($30)
533
        stq     $31,72($30)             /* a3=0 => no error */
534
 
535
.align 3
536
ret_from_sys_call:
537
        cmovne  $26,0,$19               /* $19 = 0 => non-restartable */
538
        /* check bottom half interrupts */
539
        lda     $0,intr_count
540
        ldq     $1,0($0)
541
        bne     $1,ret_from_handle_bh
542
        lda     $2,bh_active
543
        ldq     $3,0($2)
544
        lda     $2,bh_mask
545
        ldq     $4,0($2)
546
        addq    $1,1,$1
547
        and     $3,$4,$2
548
        bne     $2,handle_bottom_half
549
ret_from_handle_bh:
550
        ldq     $0,SP_OFF($30)
551
        and     $0,8,$0
552
        beq     $0,restore_all
553
ret_from_reschedule:
554
        lda     $0,need_resched
555
        lda     $1,current_set
556
        ldl     $2,0($0)
557
        lda     $4,init_task
558
        ldq     $3,0($1)
559
        bne     $2,reschedule
560
        subq    $4,$3,$4
561
        beq     $4,restore_all
562
        ldq     $4,TASK_SIGNAL($3)
563
        ldq     $16,TASK_BLOCKED($3)
564
        bic     $4,$16,$4
565
        bne     $4,signal_return
566
restore_all:
567
        RESTORE_ALL
568
        rti
569
 
570
 
571
/* PTRACE syscall handler */
572
.align 3
573
strace:
574
        /* set up signal stack, call syscall_trace */
575
        bsr     $1,do_switch_stack
576
        lda     $27,syscall_trace
577
        jsr     $26,($27),syscall_trace
578
        bsr     $1,undo_switch_stack
579
 
580
        /* get the system call number and the arguments back.. */
581
        ldq     $0,0($30)
582
        ldq     $16,SP_OFF+24($30)
583
        ldq     $17,SP_OFF+32($30)
584
        ldq     $18,SP_OFF+40($30)
585
        ldq     $19,72($30)
586
        ldq     $20,80($30)
587
        ldq     $21,88($30)
588
 
589
        /* get the system call pointer.. */
590
        lda     $1,NR_SYSCALLS($31)
591
        lda     $2,sys_call_table
592
        lda     $27,do_entSys
593
        cmpult  $0,$1,$1
594
        s8addq  $0,$2,$2
595
        beq     $1,1f
596
        ldq     $27,0($2)
597
1:      jsr     $26,($27),do_entSys
598
 
599
        /* check return.. */
600
        blt     $0,strace_error /* the call failed */
601
        stq     $31,72($30)             /* a3=0 => no error */
602
strace_success:
603
        stq     $0,0($30)               /* save return value */
604
 
605
        bsr     $1,do_switch_stack
606
        lda     $27,syscall_trace
607
        jsr     $26,($27),syscall_trace
608
        bsr     $1,undo_switch_stack
609
        br      $31,ret_from_sys_call
610
 
611
        .align  3
612
strace_error:
613
        ldq     $19,0($30)      /* old syscall nr (zero if success) */
614
        beq     $19,strace_success
615
        ldq     $20,72($30)     /* .. and this a3 */
616
 
617
        subq    $31,$0,$0       /* with error in v0 */
618
        addq    $31,1,$1        /* set a3 for errno return */
619
        stq     $0,0($30)
620
        stq     $1,72($30)      /* a3 for return */
621
 
622
        bsr     $1,do_switch_stack
623
        bis     $19,$19,$9      /* save old syscall number */
624
        bis     $20,$20,$10     /* save old a3 */
625
        lda     $27,syscall_trace
626
        jsr     $26,($27),syscall_trace
627
        bis     $9,$9,$19
628
        bis     $10,$10,$20
629
        bsr     $1,undo_switch_stack
630
 
631
        bis     $31,$31,$26     /* tell "ret_from_sys_call" that we can restart */
632
        br      $31,ret_from_sys_call
633
 
634
        .align 3
635
handle_bottom_half:
636
        /*
637
         * We're called with $0 containing the address of
638
         * 'intr_count' and $1 containing 'intr_count+1'
639
         */
640
        stq     $1,0($0)        /* intr_count = 1 */
641
        subq    $30,16,$30
642
        stq     $19,0($30)      /* save syscall nr */
643
        stq     $20,8($30)      /* and error indication (a3) */
644
        lda     $27,do_bottom_half
645
        jsr     $26,($27),do_bottom_half
646
        lda     $0,intr_count
647
        ldq     $19,0($30)
648
        ldq     $20,8($30)
649
        addq    $30,16,$30
650
        stq     $31,0($0)       /* intr_count = 0 */
651
        br      $31,ret_from_handle_bh
652
 
653
        .align 3
654
syscall_error:
655
        /*
656
         * Some system calls (e.g., ptrace) can return arbitrary
657
         * values which might normally be mistaken as error numbers.
658
         * Those functions must zero $0 (v0) directly in the stack
659
         * frame to indicate that a negative return value wasn't an
660
         * error number..
661
         */
662
        ldq     $19,0($30)      /* old syscall nr (zero if success) */
663
        beq     $19,ret_success
664
 
665
        ldq     $20,72($30)     /* .. and this a3 */
666
        subq    $31,$0,$0       /* with error in v0 */
667
        addq    $31,1,$1        /* set a3 for errno return */
668
        bis     $31,$31,$26     /* tell "ret_from_sys_call" that we can restart */
669
        stq     $1,72($30)      /* a3 for return */
670
ret_success:
671
        stq     $0,0($30)
672
        br      $31,ret_from_sys_call
673
 
674
.align 3
675
signal_return:
676
        bis     $30,$30,$17
677
        br      $1,do_switch_stack
678
        bis     $30,$30,$18
679
        lda     $27,do_signal
680
        jsr     $26,($27),do_signal
681
        lda     $30,SWITCH_STACK_SIZE($30)
682
        br      $31,restore_all
683
.end entSys
684
 
685
.align 3
686
.ent reschedule
687
reschedule:
688
        subq    $30,16,$30
689
        stq     $19,0($30)      /* save syscall nr */
690
        stq     $20,8($30)      /* and error indication (a3) */
691
        lda     $27,schedule
692
        jsr     $26,($27),schedule
693
        ldq     $19,0($30)
694
        ldq     $20,8($30)
695
        addq    $30,16,$30
696
        br      $31,ret_from_reschedule
697
.end reschedule
698
 
699
.align 3
700
.ent sys_sigreturn
701
sys_sigreturn:
702
        bis     $30,$30,$17
703
        lda     $30,-SWITCH_STACK_SIZE($30)
704
        bis     $30,$30,$18
705
        lda     $27,do_sigreturn
706
        jsr     $26,($27),do_sigreturn
707
        br      $1,undo_switch_stack
708
        br      $31,ret_from_sys_call
709
.end sys_sigreturn
710
 
711
.align 3
712
.ent sys_sigsuspend
713
sys_sigsuspend:
714
        bis     $30,$30,$17
715
        br      $1,do_switch_stack
716
        bis     $30,$30,$18
717
        lda     $27,do_sigsuspend
718
        jsr     $26,($27),do_sigsuspend
719
        lda     $30,SWITCH_STACK_SIZE($30)
720
        br      $31,ret_from_sys_call
721
.end sys_sigsuspend
722
 
723
        .align 3
724
        .globl sys_call_table
725
sys_call_table:
726
/*0*/   .quad do_entSys, sys_exit, sys_fork, sys_read, sys_write
727
        .quad do_entSys, sys_close, sys_wait4, do_entSys, sys_link
728
        .quad sys_unlink, do_entSys, sys_chdir, sys_fchdir, sys_mknod
729
        .quad sys_chmod, sys_chown, sys_brk, do_entSys, sys_lseek
730
        .quad sys_getxpid, osf_mount, osf_umount, sys_setuid, sys_getxuid
731
        .quad do_entSys, sys_ptrace, do_entSys, do_entSys, do_entSys
732
        .quad do_entSys, do_entSys, do_entSys, sys_access, do_entSys
733
        .quad do_entSys, sys_sync, sys_kill, do_entSys, sys_setpgid
734
        .quad do_entSys, sys_dup, sys_pipe, do_entSys, do_entSys
735
        .quad sys_open, do_entSys, sys_getxgid, osf_sigprocmask, do_entSys
736
/*50*/  .quad do_entSys, sys_acct, sys_sigpending, do_entSys, sys_ioctl
737
        .quad do_entSys, do_entSys, sys_symlink, sys_readlink, sys_execve
738
        .quad sys_umask, sys_chroot, do_entSys, sys_getpgrp, sys_getpagesize
739
        .quad do_entSys, osf_vfork, sys_newstat, sys_newlstat, do_entSys
740
        .quad do_entSys, osf_mmap, do_entSys, sys_munmap, sys_mprotect
741
        .quad sys_madvise, sys_vhangup, do_entSys, do_entSys, sys_getgroups
742
        /* map BSD's setpgrp to sys_setpgid for binary compatibility: */
743
        .quad sys_setgroups, do_entSys, sys_setpgid, sys_setitimer, do_entSys
744
        .quad do_entSys, sys_getitimer, sys_gethostname, sys_sethostname, sys_getdtablesize
745
        .quad sys_dup2, sys_newfstat, sys_fcntl, sys_select, do_entSys
746
        .quad sys_fsync, sys_setpriority, sys_socket, sys_connect, sys_accept
747
/*100*/ .quad osf_getpriority, sys_send, sys_recv, sys_sigreturn, sys_bind
748
        .quad sys_setsockopt, sys_listen, do_entSys, do_entSys, do_entSys
749
        .quad do_entSys, sys_sigsuspend, do_entSys, sys_recvmsg, sys_sendmsg
750
        .quad do_entSys, sys_gettimeofday, sys_getrusage, sys_getsockopt, do_entSys
751
        .quad sys_readv, sys_writev, sys_settimeofday, sys_fchown, sys_fchmod
752
        .quad sys_recvfrom, sys_setreuid, sys_setregid, sys_rename, sys_truncate
753
        .quad sys_ftruncate, sys_flock, sys_setgid, sys_sendto, sys_shutdown
754
        .quad sys_socketpair, sys_mkdir, sys_rmdir, sys_utimes, do_entSys
755
        .quad do_entSys, sys_getpeername, do_entSys, do_entSys, sys_getrlimit
756
        .quad sys_setrlimit, do_entSys, sys_setsid, sys_quotactl, do_entSys
757
/*150*/ .quad sys_getsockname, do_entSys, do_entSys, do_entSys, do_entSys
758
        .quad do_entSys, sys_sigaction, do_entSys, do_entSys, osf_getdirentries
759
        .quad osf_statfs, osf_fstatfs, do_entSys, do_entSys, do_entSys
760
        .quad osf_getdomainname, sys_setdomainname, do_entSys, do_entSys, do_entSys
761
        .quad do_entSys, do_entSys, do_entSys, do_entSys, do_entSys
762
        .quad do_entSys, do_entSys, do_entSys, do_entSys, do_entSys
763
        .quad do_entSys, do_entSys, do_entSys, do_entSys, do_entSys
764
        .quad do_entSys, do_entSys, do_entSys, do_entSys, do_entSys
765
        .quad do_entSys, do_entSys, do_entSys, do_entSys, do_entSys
766
        .quad do_entSys, do_entSys, do_entSys, do_entSys, osf_swapon
767
/*200*/ .quad sys_msgctl, sys_msgget, sys_msgrcv, sys_msgsnd, sys_semctl
768
        .quad sys_semget, sys_semop, osf_utsname, do_entSys, osf_shmat
769
        .quad sys_shmctl, sys_shmdt, sys_shmget, do_entSys, do_entSys
770
        .quad do_entSys, do_entSys, sys_msync, do_entSys, do_entSys
771
        .quad do_entSys, do_entSys, do_entSys, do_entSys, do_entSys
772
        .quad do_entSys, do_entSys, do_entSys, do_entSys, do_entSys
773
        .quad do_entSys, do_entSys, do_entSys, sys_getpgid, sys_getsid
774
        .quad do_entSys, do_entSys, do_entSys, do_entSys, do_entSys
775
        .quad do_entSys, do_entSys, do_entSys, do_entSys, osf_proplist_syscall
776
        .quad do_entSys, do_entSys, do_entSys, do_entSys, do_entSys
777
/*250*/ .quad do_entSys, osf_usleep_thread, do_entSys, do_entSys, sys_sysfs
778
        .quad do_entSys, osf_getsysinfo, osf_setsysinfo, do_entSys, do_entSys
779
        .quad do_entSys, do_entSys, do_entSys, do_entSys, do_entSys
780
        .quad do_entSys, do_entSys, do_entSys, do_entSys, do_entSys
781
        .quad do_entSys, do_entSys, do_entSys, do_entSys, do_entSys
782
        .quad do_entSys, do_entSys, do_entSys, do_entSys, do_entSys
783
        .quad do_entSys, do_entSys, do_entSys, do_entSys, do_entSys
784
        .quad do_entSys, do_entSys, do_entSys, do_entSys, do_entSys
785
        .quad do_entSys, do_entSys, do_entSys, do_entSys, do_entSys
786
        .quad do_entSys, do_entSys, do_entSys, do_entSys, do_entSys
787
/* linux-specific system calls start at 300 */
788
/*300*/ .quad sys_bdflush, sys_sethae, sys_mount, sys_adjtimex, sys_swapoff
789
        .quad sys_getdents, alpha_create_module, sys_init_module, sys_delete_module, sys_get_kernel_syms
790
        .quad sys_syslog, sys_reboot, sys_clone, sys_uselib, sys_mlock
791
        .quad sys_munlock, sys_mlockall, sys_munlockall, sys_sysinfo, sys_sysctl
792
        .quad sys_idle, sys_umount, sys_swapon, sys_times, sys_personality
793
        .quad sys_setfsuid, sys_setfsgid, sys_ustat, sys_statfs, sys_fstatfs
794
        .quad sys_sched_setparam, sys_sched_getparam, sys_sched_setscheduler, sys_sched_getscheduler, sys_sched_yield
795
        .quad sys_sched_get_priority_max, sys_sched_get_priority_min, sys_sched_rr_get_interval, do_entSys /* sys_afs_syscall */, sys_newuname
796
        .quad sys_nanosleep, sys_mremap, do_entSys, do_entSys, do_entSys
797
        .quad sys_pciconfig_read, sys_pciconfig_write, do_entSys, do_entSys, do_entSys
798
 
799
 
800
#ifdef CONFIG_KGDB
801
 
802
#define KGDB_STACK_SIZE (8*1024)
803
 
804
        .lcomm  kgdb_stack_bottom, KGDB_STACK_SIZE
805
 
806
/*
807
 * The following is the nasty part of entering KGDB.  GDB assumes that
808
 * it can access the memory below the interrupted thread's stack
809
 * pointer (SP).  This means that the stub cannot run on this stack
810
 * (interrupts could overwrite changes made by GDB).  Similarly, we do
811
 * not want to bother the GDB user with the call chain leading from
812
 * the interrupt handler to this function.  That is, the SP reported
813
 * to GDB should be the thread's SP at the point it was interrupted.  We
814
 * achieve all this by switching to KGDB's own stack before saving any
815
 * registers (of course, the PAL-generated frame is already on the stack and
816
 * we copy that part explicitly).  GDB does whatever it wants to the
817
 * thread's stack; and when it continues execution, we restore the
818
 * registers from the private stack and return from the interrupt.
819
 *
820
 * This is not re-entrant---gdb on the host probably would get confused
821
 * anyway, but we probably ought to detect that case at the least...
822
 */
823
.align 3
824
.globl  entKGDB
825
.ent    entKGDB
826
entKGDB:
827
        lda     $16,kgdb_stack_bottom
828
        lda     $16,(KGDB_STACK_SIZE-48)($16)
829
        bis     $31,$30,$17     /* save real sp in a1 */
830
        bis     $31,$16,$30     /* update sp atomically! */
831
        SAVE_ALL                /* save regular stuff */
832
        /*
833
         * Only now can we disable interrupts (swpipl may step on
834
         * t0,t8..t11, and a0):
835
         */
836
        bis     $31,7,$16
837
        call_pal PAL_swpipl
838
 
839
        /* copy PAL frame to kgdb stack: */
840
 
841
        ldq     $1,0($17)
842
        ldq     $2,8($17)
843
        ldq     $3,16($17)
844
        ldq     $4,24($17)
845
        ldq     $5,32($17)
846
        ldq     $6,40($17)
847
 
848
        stq     $1,0+184($30)
849
        stq     $2,8+184($30)
850
        stq     $3,16+184($30)
851
        stq     $4,24+184($30)
852
        stq     $5,32+184($30)
853
        stq     $6,40+184($30)
854
 
855
        /* allocate space for and save caller saved regs as well as orig sp: */
856
 
857
        lda     $30,-320($30)
858
        addq    $17,48,$17      /* pop PAL frame */
859
        stq     $17,0($30)      /* save original sp */
860
 
861
        stq      $9,0x08($30); stq $10,0x10($30); stq $11,0x18($30)
862
        stq     $12,0x20($30); stq $13,0x28($30); stq $14,0x30($30)
863
        stq     $15,0x38($30)
864
 
865
        stt     $f0,0x40($30);   stt $f1,0x48($30);   stt $f2,0x50($30);   stt $f3,0x58($30)
866
        stt     $f4,0x60($30);   stt $f5,0x68($30);   stt $f6,0x70($30);   stt $f7,0x78($30)
867
        stt     $f8,0x80($30);   stt $f9,0x88($30);   stt $f10,0x90($30);  stt $f11,0x98($30)
868
        stt     $f12,0xa0($30);  stt $f13,0xa8($30);  stt $f14,0xb0($30);  stt $f15,0xb8($30)
869
        stt     $f16,0xc0($30);  stt $f17,0xc8($30);  stt $f18,0xd0($30);  stt $f19,0xd8($30)
870
        stt     $f20,0xe0($30);  stt $f21,0xe8($30);  stt $f22,0xf0($30);  stt $f23,0xf8($30)
871
        stt     $f24,0x100($30); stt $f25,0x108($30); stt $f26,0x110($30); stt $f27,0x118($30)
872
        stt     $f28,0x120($30); stt $f29,0x128($30); stt $f30,0x130($30); stt $f31,0x138($30)
873
 
874
        bis     $31,$30,$16
875
 
876
        lda     $27,kgdb_handle_exception
877
        jsr     $26,($27),kgdb_handle_exception
878
 
879
        ldq     $17,0($30)      /* load new sp and caller-saved registers */
880
 
881
        ldq      $9,0x08($30); ldq $10,0x10($30); ldq $11,0x18($30)
882
        ldq     $12,0x20($30); ldq $13,0x28($30); ldq $14,0x30($30)
883
        ldq     $15,0x38($30)
884
 
885
        ldt     $f0,0x40($30);   ldt $f1,0x48($30);   ldt $f2,0x50($30);   ldt $f3,0x58($30)
886
        ldt     $f4,0x60($30);   ldt $f5,0x68($30);   ldt $f6,0x70($30);   ldt $f7,0x78($30)
887
        ldt     $f8,0x80($30);   ldt $f9,0x88($30);   ldt $f10,0x90($30);  ldt $f11,0x98($30)
888
        ldt     $f12,0xa0($30);  ldt $f13,0xa8($30);  ldt $f14,0xb0($30);  ldt $f15,0xb8($30)
889
        ldt     $f16,0xc0($30);  ldt $f17,0xc8($30);  ldt $f18,0xd0($30);  ldt $f19,0xd8($30)
890
        ldt     $f20,0xe0($30);  ldt $f21,0xe8($30);  ldt $f22,0xf0($30);  ldt $f23,0xf8($30)
891
        ldt     $f24,0x100($30); ldt $f25,0x108($30); ldt $f26,0x110($30); ldt $f27,0x118($30)
892
        ldt     $f28,0x120($30); ldt $f29,0x128($30); ldt $f30,0x130($30); ldt $f31,0x138($30)
893
        lda     $30,320($30)    /* pop extra register frame */
894
 
895
        /*
896
         * Copy PAL frame from kgdb stack to new stack so we can rti
897
         * to it:
898
         */
899
        ldq     $1,0+184($30)
900
        ldq     $2,8+184($30)
901
        ldq     $3,16+184($30)
902
        ldq     $4,24+184($30)
903
        ldq     $5,32+184($30)
904
        ldq     $6,40+184($30)
905
 
906
        subq    $17,48,$17      /* alloc space for PAL frame on new stack */
907
 
908
        stq     $1,0($17)
909
        stq     $2,8($17)
910
        stq     $3,16($17)
911
        stq     $4,24($17)
912
        stq     $5,32($17)
913
        stq     $6,40($17)
914
 
915
        RESTORE_ALL
916
        bis     $31,$17,$30     /* establish new sp */
917
        rti
918
 
919
.end entKGDB
920
 
921
#endif /* CONFIG_KGDB */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.