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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [hal/] [i386/] [arch/] [current/] [include/] [arch.inc] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
#ifndef CYGONCE_HAL_ARCH_INC
2
#define CYGONCE_HAL_ARCH_INC
3
##=============================================================================
4
##
5
##      arch.inc
6
##
7
##      i386 assembler header file
8
##
9
##=============================================================================
10
## ####ECOSGPLCOPYRIGHTBEGIN####
11
## -------------------------------------------
12
## This file is part of eCos, the Embedded Configurable Operating System.
13
## Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
14
##
15
## eCos is free software; you can redistribute it and/or modify it under
16
## the terms of the GNU General Public License as published by the Free
17
## Software Foundation; either version 2 or (at your option) any later
18
## version.
19
##
20
## eCos is distributed in the hope that it will be useful, but WITHOUT
21
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
22
## FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
23
## for more details.
24
##
25
## You should have received a copy of the GNU General Public License
26
## along with eCos; if not, write to the Free Software Foundation, Inc.,
27
## 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
28
##
29
## As a special exception, if other files instantiate templates or use
30
## macros or inline functions from this file, or you compile this file
31
## and link it with other works to produce a work based on this file,
32
## this file does not by itself cause the resulting work to be covered by
33
## the GNU General Public License. However the source code for this file
34
## must still be made available in accordance with section (3) of the GNU
35
## General Public License v2.
36
##
37
## This exception does not invalidate any other reasons why a work based
38
## on this file might be covered by the GNU General Public License.
39
## -------------------------------------------
40
## ####ECOSGPLCOPYRIGHTEND####
41
##=============================================================================
42
#######DESCRIPTIONBEGIN####
43
##
44
## Author(s):    nickg
45
## Contributors: nickg, pjo
46
## Date:        1999-10-15
47
## Purpose:     Architecture definitions.
48
## Description: This file contains various definitions and macros that are
49
##              useful for writing assembly code for the i386 CPU family.
50
## Usage:
51
##              #include 
52
##              ...
53
##
54
##
55
######DESCRIPTIONEND####
56
##
57
##=============================================================================
58
 
59
#include 
60
 
61
#include 
62
 
63
##-----------------------------------------------------------------------------
64
## CPU specific macros. These provide a common assembler interface to
65
## operations that may have CPU specific implementations on different
66
## variants of the architecture.
67
 
68
#ifndef CYGPKG_HAL_I386_CPU_INIT_DEFINED
69
        # Initialize CPU
70
        .macro  hal_cpu_init
71
        .endm
72
#endif /* !CYGPKG_HAL_I386_CPU_INIT_DEFINED */
73
 
74
##-----------------------------------------------------------------------------
75
 
76
#ifndef CYGPKG_HAL_I386_INTC_DEFINED
77
 
78
#ifndef CYGPKG_HAL_I386_INTC_INIT_DEFINED
79
        # initialize all interrupts to disabled
80
        .macro  hal_intc_init
81
        .endm
82
#endif
83
 
84
        .macro  hal_intc_decode vnum
85
        .endm
86
 
87
#endif
88
 
89
#------------------------------------------------------------------------------
90
# SMP support
91
 
92
#ifdef CYGPKG_HAL_SMP_SUPPORT
93
 
94
        .macro  hal_smp_init
95
#if defined(CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS)
96
        movl    $0,cyg_hal_smp_vsr_sync_flag
97
#endif
98
        .endm
99
 
100
        // Put CPU number in register
101
        .macro  hal_smp_cpu reg
102
        movl    cyg_hal_smp_local_apic,\reg
103
        movl    0x20(\reg),\reg
104
        shrl    $24,\reg
105
        .endm
106
 
107
#else
108
 
109
        .macro  hal_smp_init
110
        .endm
111
 
112
        .macro hal_smp_cpu reg
113
        movl    $0,\reg
114
        .endm
115
 
116
#endif
117
 
118
#------------------------------------------------------------------------------
119
# Stack switching macros
120
 
121
#ifndef CYG_HAL_I386_INTSTACK_MACROS_DEFINED
122
 
123
#ifdef CYGIMP_HAL_COMMON_INTERRUPTS_USE_INTERRUPT_STACK
124
 
125
#ifdef CYGPKG_HAL_SMP_SUPPORT
126
 
127
        .macro  hal_init_istack reg
128
        hal_smp_cpu %ebx
129
        movl    $__interrupt_stack_vector,%ecx
130
        movl    $CYGNUM_HAL_COMMON_INTERRUPTS_STACK_SIZE,%eax
131
        imull   %ebx,%eax
132
        addl    $__interrupt_stack_first,%eax
133
        movl    %eax,0(%ecx,%ebx,4)
134
        movl    $CYGNUM_HAL_COMMON_INTERRUPTS_STACK_SIZE,\reg
135
        addl    %eax,\reg
136
        .endm
137
 
138
        .macro  hal_load_istack reg
139
        hal_load_istack_base \reg
140
        addl    $CYGNUM_HAL_COMMON_INTERRUPTS_STACK_SIZE,\reg
141
        .endm
142
 
143
        .macro  hal_load_istack_base reg
144
        hal_smp_cpu \reg
145
        movl    $__interrupt_stack_vector,%eax
146
        movl    0(%eax,\reg,4),\reg
147
        .endm
148
 
149
#else // CYGPKG_HAL_SMP_SUPPORT
150
        .macro  hal_init_istack reg,tr
151
        movl    $__interrupt_stack,\reg         // Load interrupt stack
152
        .endm
153
 
154
        .macro  hal_load_istack reg
155
        movl    $__interrupt_stack,\reg         // Load interrupt stack
156
        .endm
157
 
158
        .macro  hal_load_istack_base reg
159
        movl    $__interrupt_stack_base,\reg    // Load interrupt stack base
160
        .endm
161
 
162
#endif // CYGPKG_HAL_SMP_SUPPORT
163
 
164
        .macro  hal_to_intstack
165
        hal_load_istack_base %ebx               // EBX = stack base
166
        movl    %ebx,%eax
167
        addl    $CYGNUM_HAL_COMMON_INTERRUPTS_STACK_SIZE,%eax
168
        cmpl    %ebx,%ebp                       # compare SP with istack base
169
        jb      1f                              # if sp < istack base, switch
170
        cmpl    %eax,%ebp                       # compare SP with istack top
171
        jbe     2f                              # if sp < istack top, dont switch
172
1:
173
        movl    %eax,%esp                       # move on to new stack
174
2:
175
        pushl   %ebp                            # Save old SP on new stack
176
        .endm
177
 
178
        .macro  hal_from_intstack
179
        popl    %esp                            # pop old SP from stack
180
        .endm
181
 
182
#define CYG_HAL_I386_INTSTACK_MACROS_DEFINED
183
 
184
 
185
#else // CYGIMP_HAL_COMMON_INTERRUPTS_USE_INTERRUPT_STACK
186
 
187
        .macro  hal_init_istack reg
188
        .endm
189
 
190
        .macro  hal_load_istack_base reg
191
        .endm
192
 
193
        .macro  hal_load_istack reg
194
        .endm
195
 
196
        .macro  hal_to_intstack
197
        .endm
198
 
199
        .macro  hal_from_intstack
200
        .endm
201
 
202
#define CYG_HAL_I386_INTSTACK_MACROS_DEFINED
203
 
204
#endif // CYGIMP_HAL_COMMON_INTERRUPTS_USE_INTERRUPT_STACK
205
 
206
#endif // CYG_HAL_I386_INTSTACK_MACROS_DEFINED
207
 
208
#------------------------------------------------------------------------------
209
# FPU macros.
210
 
211
#ifndef CYGPKG_HAL_I386_FPU_DEFINED
212
 
213
#ifdef CYGHWR_HAL_I386_FPU
214
 
215
#define CYGPKG_HAL_I386_FPU_DEFINED
216
 
217
        .macro  hal_fpu_init
218
        # Tell the CPU to use the math hardware.
219
        movl    %cr0, %eax
220
        orl     $0x32, %eax     # Set MP, ET, NE bits
221
        andl    $~0x8, %eax     # And clear TS bit
222
        movl    %eax, %cr0
223
 
224
        finit                   # and initialize...
225
 
226
        ## Enable floating point exceptions. Bit mask:
227
        ##  1 - invalid operation
228
        ##  2 - denormalized operand
229
        ##  4 - zero divide
230
        ##  8 - overflow
231
        ## 16 - underflow
232
        ## 32 - precision
233
        pushl   $0              # space for CW
234
        fstcw   0(%esp)         # store FPCW to stack
235
        movl    0(%esp),%eax    # get into EAX
236
        andb    $(~0x04),%al    # allow only zero divide exceptions
237
        movl    %eax,0(%esp)    # put back into memory
238
        fldcw   0(%esp)         # reload
239
        addl    $4,%esp         # pop value
240
 
241
#ifdef CYGHWR_HAL_I386_PENTIUM_SSE
242
        # set CR4.OSFXSR to safely use stmxcsr/ldmxcsr
243
        movl    %cr4, %eax
244
        orl     $0x200, %eax
245
        movl    %eax, %cr4
246
 
247
        ## Enable SIMD exceptions. Bit mask:
248
        ## 0x0080 - invalid operation
249
        ## 0x0100 - denormalized operand
250
        ## 0x0200 - zero divide
251
        ## 0x0400 - overflow
252
        ## 0x0800 - underflow
253
        ## 0x1000 - precision
254
        pushl   $0              # space for MXCSR
255
        stmxcsr 0(%esp)         # store MXCSR to stack
256
        movl    0(%esp),%eax    # get into EAX
257
        andw    $(~0x0200),%ax  # allow only zero divide exceptions
258
        movl    %eax,0(%esp)    # put back into memory
259
        ldmxcsr 0(%esp)         # reload
260
        addl    $4,%esp         # pop value
261
#endif
262
 
263
#ifdef CYGHWR_HAL_I386_FPU_SWITCH_LAZY
264
        # Tell the CPU to generate an FPU unavailable exception
265
        # when the FPU is first used.
266
        movl    %cr0, %eax
267
        orl     $0x8, %eax
268
        movl    %eax, %cr0
269
        # Plant a pointer to the FPU switch VSR into slot 7
270
        # of the VSR table.
271
        movl    $__fpu_switch_vsr,%eax
272
        movl    %eax,(hal_vsr_table+7*4)
273
        # Now create an FPU context on the stack so that we can take
274
        # FPU-using interrupts and exceptions before the machine starts
275
        # up.
276
        subl    $i386reg_fpucontext_size,%esp
277
        movl    $0,i386reg_fpucontext_valid(%esp)
278
        hal_smp_cpu %ebx                        # get CPU id
279
        movl    $cyg_hal_fpustate_current,%ecx  # current state table
280
        movl    %esp,0(%ecx,%ebx,4)             # save in table[cpu] entry
281
#endif
282
        .endm
283
 
284
        .macro  hal_fpu_cpu_init
285
        # Tell the CPU to use the math hardware.
286
        movl    %cr0, %eax
287
        orl     $0x32, %eax     # Set MP, ET, NE bits
288
        andl    $~0x8, %eax     # And clear TS bit
289
        movl    %eax, %cr0
290
 
291
        finit                   # and initialize...
292
 
293
        ## Enable floating point exceptions. Bit mask:
294
        ##  1 - invalid operation
295
        ##  2 - denormalized operand
296
        ##  4 - zero divide
297
        ##  8 - overflow
298
        ## 16 - underflow
299
        ## 32 - precision
300
        pushl   $0              # space for CW
301
        fstcw   0(%esp)         # store FPCW to stack
302
        movl    0(%esp),%eax    # get into EAX
303
        andb    $(~0x04),%al    # allow only zero divide exceptions
304
        movl    %eax,0(%esp)    # put back into memory
305
        fldcw   0(%esp)         # reload
306
        addl    $4,%esp         # pop value
307
 
308
#ifdef CYGHWR_HAL_I386_PENTIUM_SSE
309
        # set CR4.OSFXSR to safely use stmxcsr/ldmxcsr
310
        movl    %cr4, %eax
311
        orl     $0x200, %eax
312
        movl    %eax, %cr4
313
 
314
        ## Enable SIMD exceptions. Bit mask:
315
        ## 0x0080 - invalid operation
316
        ## 0x0100 - denormalized operand
317
        ## 0x0200 - zero divide
318
        ## 0x0400 - overflow
319
        ## 0x0800 - underflow
320
        ## 0x1000 - precision
321
        pushl   $0              # space for MXCSR
322
        stmxcsr 0(%esp)         # store MXCSR to stack
323
        movl    0(%esp),%eax    # get into EAX
324
        andw    $(~0x0200),%ax  # allow only zero divide exceptions
325
        movl    %eax,0(%esp)    # put back into memory
326
        ldmxcsr 0(%esp)         # reload
327
        addl    $4,%esp         # pop value
328
#endif
329
 
330
#ifdef CYGHWR_HAL_I386_FPU_SWITCH_LAZY
331
        # Tell the CPU to generate an FPU unavailable exception
332
        # when the FPU is first used.
333
        movl    %cr0, %eax
334
        orl     $0x8, %eax
335
        movl    %eax, %cr0
336
        # Now create an FPU context on the stack so that we can take
337
        # FPU-using interrupts and exceptions before the kernel starts
338
        # up.
339
        subl    $i386reg_fpucontext_size,%esp
340
        movl    $0,i386reg_fpucontext_valid(%esp)
341
        hal_smp_cpu %ebx                        # get CPU id
342
        movl    $cyg_hal_fpustate_current,%ecx  # current state table
343
        movl    %esp,0(%ecx,%ebx,4)             # save in table[cpu] entry
344
#endif
345
 
346
        .endm
347
 
348
#ifndef CYGHWR_HAL_I386_FPU_SWITCH_LAZY
349
 
350
        # Non-lazy CPU state switching. We simply switch the entire
351
        # FPU state on every context switch, interrupt or exception.
352
 
353
        # ------------------------------------------------------------
354
        # Context switch handling
355
 
356
        .macro  hal_fpu_push_ctx
357
        subl    $i386reg_fpstate_size,%esp      # make space
358
        fnsave  i386reg_fpstate(%esp)           # save FPU state
359
#ifdef CYGHWR_HAL_I386_PENTIUM_SSE
360
        # Save SIMD state.
361
 
362
        # FIXME. This is awfully inefficient. Need to use FXSAVE to
363
        # save FPU and SIMD at same time. FXSAVE requires a 16 byte
364
        # alignment and does not have an implicit finit as does FSAVE.
365
 
366
        stmxcsr i386reg_simd_mxcsr(%esp)
367
        movups  %xmm0,i386reg_simd_xmm0(%esp)
368
        movups  %xmm1,i386reg_simd_xmm1(%esp)
369
        movups  %xmm2,i386reg_simd_xmm2(%esp)
370
        movups  %xmm3,i386reg_simd_xmm3(%esp)
371
        movups  %xmm4,i386reg_simd_xmm4(%esp)
372
        movups  %xmm5,i386reg_simd_xmm5(%esp)
373
        movups  %xmm6,i386reg_simd_xmm6(%esp)
374
        movups  %xmm7,i386reg_simd_xmm7(%esp)
375
#endif
376
        movl    $1,i386reg_fpstate_valid(%esp)  # indicate it is valid
377
        .endm
378
 
379
        .macro  hal_fpu_pop_ctx
380
        btl     $0,i386reg_fpstate_valid(%esp)  # check ls bit of valid flag
381
        jc      1f                              # if set, restore state
382
        finit                                   # otherwise init FPU
383
#ifdef CYGHWR_HAL_I386_PENTIUM_SSE
384
        # FIXME. Anything needed here?
385
#endif
386
        jmp     2f                              # and skip restore
387
1:
388
        frstor  i386reg_fpstate(%esp)           # restore FPU state
389
#ifdef CYGHWR_HAL_I386_PENTIUM_SSE
390
        # Restore SIMD state.
391
 
392
        # FIXME. This is awfully inefficient. Need to use FXRSTOR to
393
        # restore FPU and SIMD at same time. FXRSTOR requires a 16 byte
394
        # alignment.
395
 
396
        movups  i386reg_simd_xmm0(%esp),%xmm0
397
        movups  i386reg_simd_xmm1(%esp),%xmm1
398
        movups  i386reg_simd_xmm2(%esp),%xmm2
399
        movups  i386reg_simd_xmm3(%esp),%xmm3
400
        movups  i386reg_simd_xmm4(%esp),%xmm4
401
        movups  i386reg_simd_xmm5(%esp),%xmm5
402
        movups  i386reg_simd_xmm6(%esp),%xmm6
403
        movups  i386reg_simd_xmm7(%esp),%xmm7
404
        ldmxcsr i386reg_simd_mxcsr(%esp)
405
#endif
406
2:
407
        addl    $i386reg_fpstate_size,%esp      # pop space used
408
        .endm
409
 
410
        # ------------------------------------------------------------
411
        # Interrupt and exception handling
412
 
413
        # In this configuration, the interrupt and exception code behaves in
414
        # exactly the same way as the context switch code.
415
 
416
        .macro  hal_fpu_push_int
417
        hal_fpu_push_ctx
418
        .endm
419
 
420
        .macro  hal_fpu_push_int_annex
421
        .endm
422
 
423
        .macro  hal_fpu_pop_int_annex
424
        .endm
425
 
426
        .macro  hal_fpu_pop_int
427
        hal_fpu_pop_ctx
428
        .endm
429
 
430
        .macro  hal_fpu_push_exc
431
        hal_fpu_push_ctx
432
        .endm
433
 
434
        .macro  hal_fpu_push_exc_annex
435
        .endm
436
 
437
        .macro  hal_fpu_pop_exc_annex
438
        .endm
439
 
440
        .macro  hal_fpu_pop_exc
441
        hal_fpu_pop_ctx
442
        .endm
443
 
444
#else // CYGHWR_HAL_I386_FPU_SWITCH_LAZY
445
 
446
        # Lazy CPU state switching. We defer CPU state switching until the new
447
        # thread actually uses the FPU. This state switch is handled by
448
        # __fpu_switch_vsr in vectors.S.
449
 
450
        .extern cyg_hal_fpustate_owner
451
        .extern cyg_hal_fpustate_current
452
 
453
        # ------------------------------------------------------------
454
        # Context switch handling
455
 
456
        # On context switch we simply stack a pointer to this
457
        # threads FPU context save area.
458
 
459
        .macro  hal_fpu_push_ctx
460
        hal_smp_cpu %ebx                        # Get CPU id
461
        movl    $cyg_hal_fpustate_current,%ecx  # current state table
462
        pushl   0(%ecx,%ebx,4)                  # push table[cpu] entry
463
        .endm
464
 
465
        # We do nothing here but set the CR0:TS bit to force
466
        # an exception when the FPU is next used and pop the
467
        # FPU save area pointer into the static variable.
468
 
469
        .macro  hal_fpu_pop_ctx
470
        movl    %cr0, %ecx                      # get CR0
471
        orl     $0x8, %ecx                      # set TS bit
472
        movl    %ecx, %cr0                      # restore CR0
473
        hal_smp_cpu %ebx                        # get CPU id
474
        movl    $cyg_hal_fpustate_current,%ecx  # current state table
475
        popl    0(%ecx,%ebx,4)                  # pop table[cpu] entry
476
        .endm
477
 
478
        # ------------------------------------------------------------
479
        # Interrupt handling
480
 
481
        # On entry to an interrupt we save the current threads FPU context
482
        # pointer and set the CR0:TS bit to trap any FP operations in the
483
        # interrupt.
484
 
485
        .macro  hal_fpu_push_int
486
        hal_smp_cpu %ebx                        # get CPU id
487
        movl    $cyg_hal_fpustate_current,%ecx  # current state table
488
        pushl   0(%ecx,%ebx,4)                  # push table[cpu] entry
489
        # ensure that CR0:TS bit is set
490
        movl    %cr0, %ecx                      # get CR0
491
        orl     $0x8, %ecx                      # set TS bit
492
        movl    %ecx, %cr0                      # restore CR0
493
        .endm
494
 
495
        # The following is called after we transfer to the interrupt
496
        # stack. We make space here for the FPU state of the interrupt
497
        # handler to be saved in case we get nested interrupts that use FP.
498
 
499
        .macro  hal_fpu_push_int_annex
500
        subl    $i386reg_fpucontext_size,%esp
501
        movl    $0,i386reg_fpucontext_valid(%esp)
502
        hal_smp_cpu %ebx                        # get CPU id
503
        movl    $cyg_hal_fpustate_current,%ecx  # current state table
504
        movl    %esp,0(%ecx,%ebx,4)             # save in table[cpu] entry
505
        .endm
506
 
507
        # This is invoked just before any transfer back to the thread stack.
508
        # We check whether we are the FPU state owner, and if so, abdicate.
509
        # There is no need to save the state, the next thread will load its
510
        # own state over the top of it.
511
 
512
        .macro  hal_fpu_pop_int_annex
513
        hal_smp_cpu %ebx                        # get CPU id
514
        movl    $cyg_hal_fpustate_owner,%ecx    # current state table
515
        cmpl    0(%ecx,%ebx,4),%esp             # are we FPU owner?
516
        jne     1f                              # if not, then just continue
517
        movl    $0,0(%ecx,%ebx,4)               # no one owns FPU now
518
        # ensure that CR0:TS bit is set to force a reload of
519
        # the previous FPU state
520
        movl    %cr0, %ecx                      # get CR0
521
        orl     $0x8, %ecx                      # set TS bit
522
        movl    %ecx, %cr0                      # restore CR0
523
1:
524
        addl    $i386reg_fpucontext_size,%esp   # pop FPU save area
525
        .endm
526
 
527
        # Final return from interrupt handling. Just pull the current
528
        # FPU context off the stack.
529
        .macro  hal_fpu_pop_int
530
        hal_smp_cpu %ebx                        # get CPU id
531
        movl    $cyg_hal_fpustate_current,%ecx  # current state table
532
        popl    0(%ecx,%ebx,4)                  # pop table[cpu] entry
533
        .endm
534
 
535
        # ------------------------------------------------------------
536
        # Exception handling
537
 
538
        # Whenever we take an exception, we save the current FPU state away
539
        # into its save area. This way, if we are going to end up in GDB, the
540
        # whole machine state is saved in memory.
541
 
542
        .macro  hal_fpu_push_exc
543
        hal_smp_cpu %ebx                        # get CPU id
544
        movl    $cyg_hal_fpustate_current,%ecx  # current state table
545
        pushl   0(%ecx,%ebx,4)                  # push table[cpu] entry
546
        movl    $cyg_hal_fpustate_owner,%ecx    # current owner table
547
        movl    0(%ecx,%ebx,4),%eax             # EAX = FPU state owner
548
        cmpl    $0,%eax                         # test it
549
        je      1f                              # skip if zero
550
        fnsave  i386reg_fpucontext_state(%eax)  # save state
551
#ifdef CYGHWR_HAL_I386_PENTIUM_SSE
552
        # Save SIMD state.
553
 
554
        # FIXME. This is awfully inefficient. Need to use FXSAVE to
555
        # save FPU and SIMD at same time. FXSAVE requires a 16 byte
556
        # alignment and does not have an implicit finit as does FSAVE.
557
 
558
        stmxcsr i386reg_simd_mxcsr(%eax)
559
        movups  %xmm0,i386reg_simd_xmm0(%eax)
560
        movups  %xmm1,i386reg_simd_xmm1(%eax)
561
        movups  %xmm2,i386reg_simd_xmm2(%eax)
562
        movups  %xmm3,i386reg_simd_xmm3(%eax)
563
        movups  %xmm4,i386reg_simd_xmm4(%eax)
564
        movups  %xmm5,i386reg_simd_xmm5(%eax)
565
        movups  %xmm6,i386reg_simd_xmm6(%eax)
566
        movups  %xmm7,i386reg_simd_xmm7(%eax)
567
#endif
568
        movl    $1,i386reg_fpucontext_valid(%eax) # set valid
569
        movl    $0,0(%ecx,%ebx,4)               # zero owner pointer
570
1:
571
        .endm
572
 
573
        # The rest of the exception macros behave exactly like the
574
        # interrupt ones.
575
 
576
        .macro  hal_fpu_push_exc_annex
577
        hal_fpu_push_int_annex
578
        .endm
579
 
580
        .macro  hal_fpu_pop_exc_annex
581
        hal_fpu_pop_int_annex
582
        .endm
583
 
584
        .macro  hal_fpu_pop_exc
585
        hal_fpu_pop_int
586
        .endm
587
 
588
#endif // CYGHWR_HAL_I386_FPU_SWITCH_LAZY
589
 
590
#else /* !CYGHWR_HAL_I386_FPU */
591
 
592
        # Non-FP macros.
593
 
594
        .macro  hal_fpu_init
595
        .endm
596
 
597
        .macro  hal_fpu_cpu_init
598
        .endm
599
 
600
        .macro  hal_fpu_push_ctx
601
        .endm
602
 
603
        .macro  hal_fpu_pop_ctx
604
        .endm
605
 
606
        .macro  hal_fpu_push_int
607
        .endm
608
 
609
        .macro  hal_fpu_push_int_annex
610
        .endm
611
 
612
        .macro  hal_fpu_pop_int_annex
613
        .endm
614
 
615
        .macro  hal_fpu_pop_int
616
        .endm
617
 
618
        .macro  hal_fpu_push_exc
619
        .endm
620
 
621
        .macro  hal_fpu_push_exc_annex
622
        .endm
623
 
624
        .macro  hal_fpu_pop_exc_annex
625
        .endm
626
 
627
        .macro  hal_fpu_pop_exc
628
        .endm
629
 
630
#endif
631
 
632
#endif
633
 
634
#------------------------------------------------------------------------------
635
# MMU macros.
636
 
637
#ifndef CYGPKG_HAL_I386_MMU_DEFINED
638
 
639
#define CYGPKG_HAL_I386_MMU_DEFINED
640
 
641
        .macro  hal_mmu_init
642
        .endm
643
 
644
#endif
645
 
646
#------------------------------------------------------------------------------
647
# A20 gate enable
648
 
649
#define K_RDWR                  0x60
650
#define K_STATUS                0x64
651
#define K_CMD                   0x64
652
#define K_OBUF_FUL              0x01
653
#define K_IBUF_FUL              0x02
654
#define KC_CMD_WIN              0xD0
655
#define KC_CMD_WOUT             0xD1
656
#define KB_A20                  0xDF
657
 
658
        .macro  hal_a20_enable
659
        // Enable A20 so that addresses at 1MB don't wrap around back to 0.
660
1:      inb     $K_STATUS, %al
661
        testb   $K_IBUF_FUL, %al
662
        jnz     1b
663
 
664
2:      inb     $K_STATUS, %al
665
        testb   $K_OBUF_FUL, %al
666
        jz      3f
667
        inb     $K_RDWR, %al
668
        jmp     2b
669
 
670
3:      movb    $KC_CMD_WOUT, %al
671
        outb    %al, $K_CMD
672
1:      inb     $K_STATUS, %al
673
        testb   $K_IBUF_FUL, %al
674
        jnz     1b
675
 
676
        movb    $KB_A20, %al
677
        outb    %al, $K_RDWR
678
1:      inb     $K_STATUS, %al
679
        testb   $K_IBUF_FUL, %al
680
        jnz     1b
681
        .endm
682
 
683
#------------------------------------------------------------------------------
684
# MEMC macros.
685
# This version simply enables the A20 gate.
686
 
687
#ifndef CYGPKG_HAL_I386_MEMC_DEFINED
688
 
689
        .macro  hal_memc_init
690
        hal_a20_enable
691
        .endm
692
 
693
#endif
694
 
695
#------------------------------------------------------------------------------
696
# Cache macros.
697
 
698
#ifndef CYGPKG_HAL_I386_CACHE_DEFINED
699
 
700
        .macro  hal_cache_init
701
        .endm
702
 
703
#endif
704
 
705
#------------------------------------------------------------------------------
706
# Diagnostics macros.
707
 
708
#ifndef CYGPKG_HAL_I386_DIAG_DEFINED
709
 
710
        .macro  hal_diag_init
711
        .endm
712
 
713
        .macro  hal_diag_excpt_start
714
        .endm
715
 
716
        .macro  hal_diag_intr_start
717
        .endm
718
 
719
        .macro  hal_diag_restore
720
        .endm
721
#endif
722
 
723
#------------------------------------------------------------------------------
724
# Timer initialization.
725
 
726
#ifndef CYGPKG_HAL_I386_TIMER_DEFINED
727
 
728
        .macro  hal_timer_init
729
        .endm
730
 
731
#endif
732
 
733
#------------------------------------------------------------------------------
734
# Monitor initialization.
735
 
736
#ifndef CYGPKG_HAL_I386_MON_DEFINED
737
 
738
        .macro  hal_mon_init
739
        .endm
740
 
741
#endif
742
 
743
#------------------------------------------------------------------------------
744
#endif // ifndef CYGONCE_HAL_ARCH_INC
745
# end of arch.inc

powered by: WebSVN 2.1.0

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