~john-koepi/ubuntu/trusty/golang/default

« back to all changes in this revision

Viewing changes to src/cmd/8a/l.s

  • Committer: Bazaar Package Importer
  • Author(s): Ondřej Surý
  • Date: 2011-08-03 17:04:59 UTC
  • mfrom: (14.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20110803170459-wzd99m3567y80ila
Tags: 1:59-1
* Imported Upstream version 59
* Refresh patches to a new release
* Fix FTBFS on ARM (Closes: #634270)
* Update version.bash to work with Debian packaging and not hg
  repository

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// Inferno utils/8a/l.s
2
 
// http://code.google.com/p/inferno-os/source/browse/utils/8a/l.s
3
 
//
4
 
//      Copyright © 1994-1999 Lucent Technologies Inc.  All rights reserved.
5
 
//      Portions Copyright © 1995-1997 C H Forsyth (forsyth@terzarima.net)
6
 
//      Portions Copyright © 1997-1999 Vita Nuova Limited
7
 
//      Portions Copyright © 2000-2007 Vita Nuova Holdings Limited (www.vitanuova.com)
8
 
//      Portions Copyright © 2004,2006 Bruce Ellis
9
 
//      Portions Copyright © 2005-2007 C H Forsyth (forsyth@terzarima.net)
10
 
//      Revisions Copyright © 2000-2007 Lucent Technologies Inc. and others
11
 
//      Portions Copyright © 2009 The Go Authors.  All rights reserved.
12
 
//
13
 
// Permission is hereby granted, free of charge, to any person obtaining a copy
14
 
// of this software and associated documentation files (the "Software"), to deal
15
 
// in the Software without restriction, including without limitation the rights
16
 
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17
 
// copies of the Software, and to permit persons to whom the Software is
18
 
// furnished to do so, subject to the following conditions:
19
 
//
20
 
// The above copyright notice and this permission notice shall be included in
21
 
// all copies or substantial portions of the Software.
22
 
//
23
 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24
 
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
 
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
26
 
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27
 
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28
 
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
29
 
// THE SOFTWARE.
30
 
 
31
 
/*
32
 
 * Memory and machine-specific definitions.  Used in C and assembler.
33
 
 */
34
 
 
35
 
/*
36
 
 * Sizes
37
 
 */
38
 
#define BI2BY           8                       /* bits per byte */
39
 
#define BI2WD           32                      /* bits per word */
40
 
#define BY2WD           4                       /* bytes per word */
41
 
#define BY2PG           4096                    /* bytes per page */
42
 
#define WD2PG           (BY2PG/BY2WD)           /* words per page */
43
 
#define PGSHIFT         12                      /* log(BY2PG) */
44
 
#define PGROUND(s)      (((s)+(BY2PG-1))&~(BY2PG-1))
45
 
 
46
 
#define MAXMACH         1                       /* max # cpus system can run */
47
 
 
48
 
/*
49
 
 * Time
50
 
 */
51
 
#define HZ              (20)                    /* clock frequency */
52
 
#define MS2HZ           (1000/HZ)               /* millisec per clock tick */
53
 
#define TK2SEC(t)       ((t)/HZ)                /* ticks to seconds */
54
 
#define TK2MS(t)        ((((ulong)(t))*1000)/HZ)        /* ticks to milliseconds */
55
 
#define MS2TK(t)        ((((ulong)(t))*HZ)/1000)        /* milliseconds to ticks */
56
 
 
57
 
/*
58
 
 * Fundamental addresses
59
 
 */
60
 
 
61
 
/*
62
 
 *  Address spaces
63
 
 *
64
 
 *  User is at 0-2GB
65
 
 *  Kernel is at 2GB-4GB
66
 
 *
67
 
 *  To avoid an extra page map, both the user stack (USTKTOP) and
68
 
 *  the temporary user stack (TSTKTOP) should be in the the same
69
 
 *  4 meg.
70
 
 */
71
 
#define UZERO           0                       /* base of user address space */
72
 
#define UTZERO          (UZERO+BY2PG)           /* first address in user text */
73
 
#define KZERO           0x80000000              /* base of kernel address space */
74
 
#define KTZERO          KZERO                   /* first address in kernel text */
75
 
#define USERADDR        0xC0000000              /* struct User */
76
 
#define UREGADDR        (USERADDR+BY2PG-4*19)   
77
 
#define TSTKTOP         USERADDR                /* end of new stack in sysexec */
78
 
#define TSTKSIZ 10
79
 
#define USTKTOP         (TSTKTOP-TSTKSIZ*BY2PG) /* byte just beyond user stack */
80
 
#define USTKSIZE        (16*1024*1024 - TSTKSIZ*BY2PG)  /* size of user stack */
81
 
#define ROMBIOS         (KZERO|0xF0000)
82
 
 
83
 
#define MACHSIZE        4096
84
 
 
85
 
#define isphys(x) (((ulong)x)&KZERO)
86
 
 
87
 
/*
88
 
 *  known 80386 segments (in GDT) and their selectors
89
 
 */
90
 
#define NULLSEG 0       /* null segment */
91
 
#define KDSEG   1       /* kernel data/stack */
92
 
#define KESEG   2       /* kernel executable */ 
93
 
#define UDSEG   3       /* user data/stack */
94
 
#define UESEG   4       /* user executable */
95
 
#define TSSSEG  5       /* task segment */
96
 
 
97
 
#define SELGDT  (0<<3)  /* selector is in gdt */
98
 
#define SELLDT  (1<<3)  /* selector is in ldt */
99
 
 
100
 
#define SELECTOR(i, t, p)       (((i)<<3) | (t) | (p))
101
 
 
102
 
#define NULLSEL SELECTOR(NULLSEG, SELGDT, 0)
103
 
#define KESEL   SELECTOR(KESEG, SELGDT, 0)
104
 
#define KDSEL   SELECTOR(KDSEG, SELGDT, 0)
105
 
#define UESEL   SELECTOR(UESEG, SELGDT, 3)
106
 
#define UDSEL   SELECTOR(UDSEG, SELGDT, 3)
107
 
#define TSSSEL  SELECTOR(TSSSEG, SELGDT, 0)
108
 
 
109
 
/*
110
 
 *  fields in segment descriptors
111
 
 */
112
 
#define SEGDATA (0x10<<8)       /* data/stack segment */
113
 
#define SEGEXEC (0x18<<8)       /* executable segment */
114
 
#define SEGTSS  (0x9<<8)        /* TSS segment */
115
 
#define SEGCG   (0x0C<<8)       /* call gate */
116
 
#define SEGIG   (0x0E<<8)       /* interrupt gate */
117
 
#define SEGTG   (0x0F<<8)       /* task gate */
118
 
#define SEGTYPE (0x1F<<8)
119
 
 
120
 
#define SEGP    (1<<15)         /* segment present */
121
 
#define SEGPL(x) ((x)<<13)      /* priority level */
122
 
#define SEGB    (1<<22)         /* granularity 1==4k (for expand-down) */
123
 
#define SEGG    (1<<23)         /* granularity 1==4k (for other) */
124
 
#define SEGE    (1<<10)         /* expand down */
125
 
#define SEGW    (1<<9)          /* writable (for data/stack) */
126
 
#define SEGR    (1<<9)          /* readable (for code) */
127
 
#define SEGD    (1<<22)         /* default 1==32bit (for code) */
128
 
 
129
 
/*
130
 
 *  virtual MMU
131
 
 */
132
 
#define PTEMAPMEM       (1024*1024)     /* ??? */       
133
 
#define SEGMAPSIZE      16              /* ??? */
134
 
#define PTEPERTAB       (PTEMAPMEM/BY2PG)       /* ??? */
135
 
#define PPN(x)          ((x)&~(BY2PG-1))
136
 
 
137
 
/*
138
 
 *  physical MMU
139
 
 */
140
 
#define PTEVALID        (1<<0)
141
 
#define PTEUNCACHED     0               /* everything is uncached */
142
 
#define PTEWRITE        (1<<1)
143
 
#define PTERONLY        (0<<1)
144
 
#define PTEKERNEL       (0<<2)
145
 
#define PTEUSER         (1<<2)
146
 
 
147
 
/*
148
 
 *  flag register bits that we care about
149
 
 */
150
 
#define IFLAG   0x200
151
 
 
152
 
#define OP16    BYTE    $0x66
153
 
 
154
 
/*
155
 
 *      about to walk all over ms/dos - turn off interrupts
156
 
 */
157
 
TEXT    origin(SB),$0
158
 
 
159
 
        CLI
160
 
 
161
 
#ifdef BOOT
162
 
/*
163
 
 *      This part of l.s is used only in the boot kernel.
164
 
 *      It assumes that we are in real address mode, i.e.,
165
 
 *      that we look like an 8086.
166
 
 */
167
 
/*
168
 
 *      relocate everything to a half meg and jump there
169
 
 *      - looks wierd because it is being assembled by a 32 bit
170
 
 *        assembler for a 16 bit world
171
 
 */
172
 
        MOVL    $0,BX
173
 
        INCL    BX
174
 
        SHLL    $15,BX
175
 
        MOVL    BX,CX
176
 
        MOVW    BX,ES
177
 
        MOVL    $0,SI
178
 
        MOVL    SI,DI
179
 
        CLD; REP; MOVSL
180
 
/*      JMPFAR  0X8000:$lowcore(SB) /**/
181
 
         BYTE   $0xEA
182
 
         WORD   $lowcore(SB)
183
 
         WORD   $0X8000
184
 
 
185
 
TEXT    lowcore(SB),$0
186
 
 
187
 
/*
188
 
 *      now that we're in low core, update the DS
189
 
 */
190
 
 
191
 
        MOVW    BX,DS
192
 
 
193
 
/*
194
 
 *      goto protected mode
195
 
 */
196
 
/*      MOVL    tgdtptr(SB),GDTR /**/
197
 
         BYTE   $0x0f
198
 
         BYTE   $0x01
199
 
         BYTE   $0x16
200
 
         WORD   $tgdtptr(SB)
201
 
        MOVL    CR0,AX
202
 
        ORL     $1,AX
203
 
        MOVL    AX,CR0
204
 
 
205
 
/*
206
 
 *      clear prefetch queue (wierd code to avoid optimizations)
207
 
 */
208
 
        CLC
209
 
        JCC     flush
210
 
        MOVL    AX,AX
211
 
flush:
212
 
 
213
 
/*
214
 
 *      set all segs
215
 
 */
216
 
/*      MOVW    $SELECTOR(1, SELGDT, 0),AX      /**/
217
 
         BYTE   $0xc7
218
 
         BYTE   $0xc0
219
 
         WORD   $SELECTOR(1, SELGDT, 0)
220
 
        MOVW    AX,DS
221
 
        MOVW    AX,SS
222
 
        MOVW    AX,ES
223
 
        MOVW    AX,FS
224
 
        MOVW    AX,GS
225
 
 
226
 
/*      JMPFAR  SELECTOR(2, SELGDT, 0):$mode32bit(SB) /**/
227
 
         BYTE   $0x66
228
 
         BYTE   $0xEA
229
 
         LONG   $mode32bit-KZERO(SB)
230
 
         WORD   $SELECTOR(2, SELGDT, 0)
231
 
 
232
 
TEXT    mode32bit(SB),$0
233
 
 
234
 
#endif BOOT
235
 
 
236
 
        /*
237
 
         * Clear BSS
238
 
         */
239
 
        LEAL    edata-KZERO(SB),SI
240
 
        MOVL    SI,DI
241
 
        ADDL    $4,DI
242
 
        MOVL    $0,AX
243
 
        MOVL    AX,(SI)
244
 
        LEAL    end-KZERO(SB),CX
245
 
        SUBL    DI,CX
246
 
        SHRL    $2,CX
247
 
        CLD; REP; MOVSL
248
 
 
249
 
        /*
250
 
         *  make a bottom level page table page that maps the first
251
 
         *  16 meg of physical memory
252
 
         */
253
 
        LEAL    tpt-KZERO(SB),AX        /* get phys addr of temporary page table */
254
 
        ADDL    $(BY2PG-1),AX           /* must be page aligned */
255
 
        ANDL    $(~(BY2PG-1)),AX        /* ... */
256
 
        MOVL    $(4*1024),CX            /* pte's per page */
257
 
        MOVL    $((((4*1024)-1)<<PGSHIFT)|PTEVALID|PTEKERNEL|PTEWRITE),BX
258
 
setpte:
259
 
        MOVL    BX,-4(AX)(CX*4)
260
 
        SUBL    $(1<<PGSHIFT),BX
261
 
        LOOP    setpte
262
 
 
263
 
        /*
264
 
         *  make a top level page table page that maps the first
265
 
         *  16 meg of memory to 0 thru 16meg and to KZERO thru KZERO+16meg
266
 
         */
267
 
        MOVL    AX,BX
268
 
        ADDL    $(4*BY2PG),AX
269
 
        ADDL    $(PTEVALID|PTEKERNEL|PTEWRITE),BX
270
 
        MOVL    BX,0(AX)
271
 
        MOVL    BX,((((KZERO>>1)&0x7FFFFFFF)>>(2*PGSHIFT-1-4))+0)(AX)
272
 
        ADDL    $BY2PG,BX
273
 
        MOVL    BX,4(AX)
274
 
        MOVL    BX,((((KZERO>>1)&0x7FFFFFFF)>>(2*PGSHIFT-1-4))+4)(AX)
275
 
        ADDL    $BY2PG,BX
276
 
        MOVL    BX,8(AX)
277
 
        MOVL    BX,((((KZERO>>1)&0x7FFFFFFF)>>(2*PGSHIFT-1-4))+8)(AX)
278
 
        ADDL    $BY2PG,BX
279
 
        MOVL    BX,12(AX)
280
 
        MOVL    BX,((((KZERO>>1)&0x7FFFFFFF)>>(2*PGSHIFT-1-4))+12)(AX)
281
 
 
282
 
        /*
283
 
         *  point processor to top level page & turn on paging
284
 
         */
285
 
        MOVL    AX,CR3
286
 
        MOVL    CR0,AX
287
 
        ORL     $0X80000000,AX
288
 
        ANDL    $~(0x8|0x2),AX  /* TS=0, MP=0 */
289
 
        MOVL    AX,CR0
290
 
 
291
 
        /*
292
 
         *  use a jump to an absolute location to get the PC into
293
 
         *  KZERO.
294
 
         */
295
 
        LEAL    tokzero(SB),AX
296
 
        JMP*    AX
297
 
 
298
 
TEXT    tokzero(SB),$0
299
 
 
300
 
        /*
301
 
         *  stack and mach
302
 
         */
303
 
        MOVL    $mach0(SB),SP
304
 
        MOVL    SP,m(SB)
305
 
        MOVL    $0,0(SP)
306
 
        ADDL    $(MACHSIZE-4),SP        /* start stack under machine struct */
307
 
        MOVL    $0, u(SB)
308
 
 
309
 
        /*
310
 
         *  clear flags
311
 
         */
312
 
        MOVL    $0,AX
313
 
        PUSHL   AX
314
 
        POPFL
315
 
 
316
 
        CALL    main(SB)
317
 
 
318
 
loop:
319
 
        JMP     loop
320
 
 
321
 
GLOBL   mach0+0(SB), $MACHSIZE
322
 
GLOBL   u(SB), $4
323
 
GLOBL   m(SB), $4
324
 
GLOBL   tpt(SB), $(BY2PG*6)
325
 
 
326
 
/*
327
 
 *  gdt to get us to 32-bit/segmented/unpaged mode
328
 
 */
329
 
TEXT    tgdt(SB),$0
330
 
 
331
 
        /* null descriptor */
332
 
        LONG    $0
333
 
        LONG    $0
334
 
 
335
 
        /* data segment descriptor for 4 gigabytes (PL 0) */
336
 
        LONG    $(0xFFFF)
337
 
        LONG    $(SEGG|SEGB|(0xF<<16)|SEGP|SEGPL(0)|SEGDATA|SEGW)
338
 
 
339
 
        /* exec segment descriptor for 4 gigabytes (PL 0) */
340
 
        LONG    $(0xFFFF)
341
 
        LONG    $(SEGG|SEGD|(0xF<<16)|SEGP|SEGPL(0)|SEGEXEC|SEGR)
342
 
 
343
 
/*
344
 
 *  pointer to initial gdt
345
 
 */
346
 
TEXT    tgdtptr(SB),$0
347
 
 
348
 
        WORD    $(3*8)
349
 
        LONG    $tgdt-KZERO(SB)
350
 
 
351
 
/*
352
 
 *  input a byte
353
 
 */
354
 
TEXT    inb(SB),$0
355
 
 
356
 
        MOVL    p+0(FP),DX
357
 
        XORL    AX,AX
358
 
        INB
359
 
        RET
360
 
 
361
 
/*
362
 
 *  output a byte
363
 
 */
364
 
TEXT    outb(SB),$0
365
 
 
366
 
        MOVL    p+0(FP),DX
367
 
        MOVL    b+4(FP),AX
368
 
        OUTB
369
 
        RET
370
 
 
371
 
/*
372
 
 *  input a string of shorts from a port
373
 
 */
374
 
TEXT    inss(SB),$0
375
 
        MOVL    p+0(FP),DX
376
 
        MOVL    a+4(FP),DI
377
 
        MOVL    c+8(FP),CX
378
 
        CLD; REP; OP16; INSL
379
 
        RET
380
 
 
381
 
/*
382
 
 *  output a string of shorts to a port
383
 
 */
384
 
TEXT    outss(SB),$0
385
 
        MOVL    p+0(FP),DX
386
 
        MOVL    a+4(FP),SI
387
 
        MOVL    c+8(FP),CX
388
 
        CLD; REP; OP16; OUTSL
389
 
        RET
390
 
 
391
 
/*
392
 
 *  test and set
393
 
 */
394
 
TEXT    tas(SB),$0
395
 
        MOVL    $0xdeadead,AX
396
 
        MOVL    l+0(FP),BX
397
 
        XCHGL   AX,(BX)
398
 
        RET
399
 
 
400
 
/*
401
 
 *  routines to load/read various system registers
402
 
 */
403
 
GLOBL   idtptr(SB),$6
404
 
TEXT    putidt(SB),$0           /* interrupt descriptor table */
405
 
        MOVL    t+0(FP),AX
406
 
        MOVL    AX,idtptr+2(SB)
407
 
        MOVL    l+4(FP),AX
408
 
        MOVW    AX,idtptr(SB)
409
 
        MOVL    idtptr(SB),IDTR
410
 
        RET
411
 
 
412
 
GLOBL   gdtptr(SB),$6
413
 
TEXT    putgdt(SB),$0           /* global descriptor table */
414
 
        MOVL    t+0(FP),AX
415
 
        MOVL    AX,gdtptr+2(SB)
416
 
        MOVL    l+4(FP),AX
417
 
        MOVW    AX,gdtptr(SB)
418
 
        MOVL    gdtptr(SB),GDTR
419
 
        RET
420
 
 
421
 
TEXT    putcr3(SB),$0           /* top level page table pointer */
422
 
        MOVL    t+0(FP),AX
423
 
        MOVL    AX,CR3
424
 
        RET
425
 
 
426
 
TEXT    puttr(SB),$0            /* task register */
427
 
        MOVL    t+0(FP),AX
428
 
        MOVW    AX,TASK
429
 
        RET
430
 
 
431
 
TEXT    getcr0(SB),$0           /* coprocessor bits */
432
 
        MOVL    CR0,AX
433
 
        RET
434
 
 
435
 
TEXT    getcr2(SB),$0           /* fault address */
436
 
        MOVL    CR2,AX
437
 
        RET
438
 
 
439
 
#define FPOFF\
440
 
        WAIT;\
441
 
        MOVL    CR0,AX;\
442
 
        ORL     $0x4,AX         /* EM=1 */;\
443
 
        MOVL    AX,CR0
444
 
 
445
 
#define FPON\
446
 
        MOVL    CR0,AX;\
447
 
        ANDL    $~0x4,AX        /* EM=0 */;\
448
 
        MOVL    AX,CR0
449
 
        
450
 
TEXT    fpoff(SB),$0            /* turn off floating point */
451
 
        FPOFF
452
 
        RET
453
 
 
454
 
TEXT    fpinit(SB),$0           /* turn on & init the floating point */
455
 
        FPON
456
 
        FINIT
457
 
        WAIT
458
 
        PUSHW   $0x0330
459
 
        FLDCW   0(SP)           /* ignore underflow/precision, signal others */
460
 
        POPW    AX
461
 
        WAIT
462
 
        RET
463
 
 
464
 
TEXT    fpsave(SB),$0           /* save floating point state and turn off */
465
 
        MOVL    p+0(FP),AX
466
 
        WAIT
467
 
        FSAVE   0(AX)
468
 
        FPOFF
469
 
        RET
470
 
 
471
 
TEXT    fprestore(SB),$0        /* turn on floating point and restore regs */
472
 
        FPON
473
 
        MOVL    p+0(FP),AX
474
 
        FRSTOR  0(AX)
475
 
        WAIT
476
 
        RET
477
 
 
478
 
TEXT    fpstatus(SB),$0         /* get floating point status */
479
 
        FSTSW   AX
480
 
        RET
481
 
 
482
 
/*
483
 
 *  special traps
484
 
 */
485
 
TEXT    intr0(SB),$0
486
 
        PUSHL   $0
487
 
        PUSHL   $0
488
 
        JMP     intrcommon
489
 
TEXT    intr1(SB),$0
490
 
        PUSHL   $0
491
 
        PUSHL   $1
492
 
        JMP     intrcommon
493
 
TEXT    intr2(SB),$0
494
 
        PUSHL   $0
495
 
        PUSHL   $2
496
 
        JMP     intrcommon
497
 
TEXT    intr3(SB),$0
498
 
        PUSHL   $0
499
 
        PUSHL   $3
500
 
        JMP     intrcommon
501
 
TEXT    intr4(SB),$0
502
 
        PUSHL   $0
503
 
        PUSHL   $4
504
 
        JMP     intrcommon
505
 
TEXT    intr5(SB),$0
506
 
        PUSHL   $0
507
 
        PUSHL   $5
508
 
        JMP     intrcommon
509
 
TEXT    intr6(SB),$0
510
 
        PUSHL   $0
511
 
        PUSHL   $6
512
 
        JMP     intrcommon
513
 
TEXT    intr7(SB),$0
514
 
        PUSHL   $0
515
 
        PUSHL   $7
516
 
        JMP     intrcommon
517
 
TEXT    intr8(SB),$0
518
 
        PUSHL   $8
519
 
        JMP     intrscommon
520
 
TEXT    intr9(SB),$0
521
 
        PUSHL   $0
522
 
        PUSHL   $9
523
 
        JMP     intrcommon
524
 
TEXT    intr10(SB),$0
525
 
        PUSHL   $10
526
 
        JMP     intrscommon
527
 
TEXT    intr11(SB),$0
528
 
        PUSHL   $11
529
 
        JMP     intrscommon
530
 
TEXT    intr12(SB),$0
531
 
        PUSHL   $12
532
 
        JMP     intrscommon
533
 
TEXT    intr13(SB),$0
534
 
        PUSHL   $13
535
 
        JMP     intrscommon
536
 
TEXT    intr14(SB),$0
537
 
        PUSHL   $14
538
 
        JMP     intrscommon
539
 
TEXT    intr15(SB),$0
540
 
        PUSHL   $0
541
 
        PUSHL   $15
542
 
        JMP     intrcommon
543
 
TEXT    intr16(SB),$0
544
 
        PUSHL   $0
545
 
        PUSHL   $16
546
 
        JMP     intrcommon
547
 
TEXT    intr24(SB),$0
548
 
        PUSHL   $0
549
 
        PUSHL   $24
550
 
        JMP     intrcommon
551
 
TEXT    intr25(SB),$0
552
 
        PUSHL   $0
553
 
        PUSHL   $25
554
 
        JMP     intrcommon
555
 
TEXT    intr26(SB),$0
556
 
        PUSHL   $0
557
 
        PUSHL   $26
558
 
        JMP     intrcommon
559
 
TEXT    intr27(SB),$0
560
 
        PUSHL   $0
561
 
        PUSHL   $27
562
 
        JMP     intrcommon
563
 
TEXT    intr28(SB),$0
564
 
        PUSHL   $0
565
 
        PUSHL   $28
566
 
        JMP     intrcommon
567
 
TEXT    intr29(SB),$0
568
 
        PUSHL   $0
569
 
        PUSHL   $29
570
 
        JMP     intrcommon
571
 
TEXT    intr30(SB),$0
572
 
        PUSHL   $0
573
 
        PUSHL   $30
574
 
        JMP     intrcommon
575
 
TEXT    intr31(SB),$0
576
 
        PUSHL   $0
577
 
        PUSHL   $31
578
 
        JMP     intrcommon
579
 
TEXT    intr32(SB),$0
580
 
        PUSHL   $0
581
 
        PUSHL   $16
582
 
        JMP     intrcommon
583
 
TEXT    intr33(SB),$0
584
 
        PUSHL   $0
585
 
        PUSHL   $33
586
 
        JMP     intrcommon
587
 
TEXT    intr34(SB),$0
588
 
        PUSHL   $0
589
 
        PUSHL   $34
590
 
        JMP     intrcommon
591
 
TEXT    intr35(SB),$0
592
 
        PUSHL   $0
593
 
        PUSHL   $35
594
 
        JMP     intrcommon
595
 
TEXT    intr36(SB),$0
596
 
        PUSHL   $0
597
 
        PUSHL   $36
598
 
        JMP     intrcommon
599
 
TEXT    intr37(SB),$0
600
 
        PUSHL   $0
601
 
        PUSHL   $37
602
 
        JMP     intrcommon
603
 
TEXT    intr38(SB),$0
604
 
        PUSHL   $0
605
 
        PUSHL   $38
606
 
        JMP     intrcommon
607
 
TEXT    intr39(SB),$0
608
 
        PUSHL   $0
609
 
        PUSHL   $39
610
 
        JMP     intrcommon
611
 
TEXT    intr64(SB),$0
612
 
        PUSHL   $0
613
 
        PUSHL   $64
614
 
        JMP     intrcommon
615
 
TEXT    intrbad(SB),$0
616
 
        PUSHL   $0
617
 
        PUSHL   $0x1ff
618
 
        JMP     intrcommon
619
 
 
620
 
intrcommon:
621
 
        PUSHL   DS
622
 
        PUSHL   ES
623
 
        PUSHL   FS
624
 
        PUSHL   GS
625
 
        PUSHAL
626
 
        MOVL    $(KDSEL),AX
627
 
        MOVW    AX,DS
628
 
        MOVW    AX,ES
629
 
        LEAL    0(SP),AX
630
 
        PUSHL   AX
631
 
        CALL    trap(SB)
632
 
        POPL    AX
633
 
        POPAL
634
 
        POPL    GS
635
 
        POPL    FS
636
 
        POPL    ES
637
 
        POPL    DS
638
 
        ADDL    $8,SP   /* error code and trap type */
639
 
        IRETL
640
 
 
641
 
intrscommon:
642
 
        PUSHL   DS
643
 
        PUSHL   ES
644
 
        PUSHL   FS
645
 
        PUSHL   GS
646
 
        PUSHAL
647
 
        MOVL    $(KDSEL),AX
648
 
        MOVW    AX,DS
649
 
        MOVW    AX,ES
650
 
        LEAL    0(SP),AX
651
 
        PUSHL   AX
652
 
        CALL    trap(SB)
653
 
        POPL    AX
654
 
        POPAL
655
 
        POPL    GS
656
 
        POPL    FS
657
 
        POPL    ES
658
 
        POPL    DS
659
 
        ADDL    $8,SP   /* error code and trap type */
660
 
        IRETL
661
 
 
662
 
/*
663
 
 *  interrupt level is interrupts on or off
664
 
 */
665
 
TEXT    spllo(SB),$0
666
 
        PUSHFL
667
 
        POPL    AX
668
 
        STI
669
 
        RET
670
 
 
671
 
TEXT    splhi(SB),$0
672
 
        PUSHFL
673
 
        POPL    AX
674
 
        CLI
675
 
        RET
676
 
 
677
 
TEXT    splx(SB),$0
678
 
        MOVL    s+0(FP),AX
679
 
        PUSHL   AX
680
 
        POPFL
681
 
        RET
682
 
 
683
 
/*
684
 
 *  do nothing whatsoever till interrupt happens
685
 
 */
686
 
TEXT    idle(SB),$0
687
 
        HLT
688
 
        RET
689
 
 
690
 
/*
691
 
 *  label consists of a stack pointer and a PC
692
 
 */
693
 
TEXT    gotolabel(SB),$0
694
 
        MOVL    l+0(FP),AX
695
 
        MOVL    0(AX),SP        /* restore sp */
696
 
        MOVL    4(AX),AX        /* put return pc on the stack */
697
 
        MOVL    AX,0(SP)
698
 
        MOVL    $1,AX           /* return 1 */
699
 
        RET
700
 
 
701
 
TEXT    setlabel(SB),$0
702
 
        MOVL    l+0(FP),AX
703
 
        MOVL    SP,0(AX)        /* store sp */
704
 
        MOVL    0(SP),BX        /* store return pc */
705
 
        MOVL    BX,4(AX)
706
 
        MOVL    $0,AX           /* return 0 */
707
 
        RET
708
 
 
709
 
/*
710
 
 *  Used to get to the first process.
711
 
 *  Set up an interrupt return frame and IRET to user level.
712
 
 */
713
 
TEXT    touser(SB),$0
714
 
        PUSHL   $(UDSEL)                /* old ss */
715
 
        PUSHL   $(USTKTOP)              /* old sp */
716
 
        PUSHFL                          /* old flags */
717
 
        PUSHL   $(UESEL)                /* old cs */
718
 
        PUSHL   $(UTZERO+32)            /* old pc */
719
 
        MOVL    $(UDSEL),AX
720
 
        MOVW    AX,DS
721
 
        MOVW    AX,ES
722
 
        MOVW    AX,GS
723
 
        MOVW    AX,FS
724
 
        IRETL
725
 
 
726
 
/*
727
 
 *  set configuration register
728
 
 */
729
 
TEXT    config(SB),$0
730
 
        MOVL    l+0(FP),AX
731
 
        MOVL    $0x3F3,DX
732
 
        OUTB
733
 
        OUTB
734
 
        RET