source: mainline/arch/ia32/src/asm.S@ 6ed5352

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 6ed5352 was 44c259c, checked in by Martin Decky <martin@…>, 20 years ago

remove obsolete in-kernel userspace code
remove CONFIG_USERSPACE switch, uspace support is configured at run-time

  • Property mode set to 100644
File size: 3.2 KB
RevLine 
[f761f1eb]1#
2# Copyright (C) 2001-2004 Jakub Jermar
3# All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions
7# are met:
8#
9# - Redistributions of source code must retain the above copyright
10# notice, this list of conditions and the following disclaimer.
11# - Redistributions in binary form must reproduce the above copyright
12# notice, this list of conditions and the following disclaimer in the
13# documentation and/or other materials provided with the distribution.
14# - The name of the author may not be used to endorse or promote products
15# derived from this software without specific prior written permission.
16#
17# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27#
28
[da585a52]29## very low and hardware-level functions
[f761f1eb]30
[76857d1]31# Mask for interrupts 0 - 31 (bits 0 - 31) where 0 means that int has no error word
32# and 1 means interrupt with error word
[59532eb]33#define ERROR_WORD_INTERRUPT_LIST 0x00027D00
34
[f761f1eb]35.text
36
37.global paging_on
38.global enable_l_apic_in_msr
39.global interrupt_handlers
[da585a52]40
41## Turn paging on
42#
43# Enable paging and write-back caching in CR0.
44#
[f761f1eb]45paging_on:
[24bd23a]46 movl %cr0,%edx
47 orl $(1<<31),%edx # paging on
48 andl $~((1<<30)|(1<<29)),%edx # clear Cache Disable and not Write Though
49 movl %edx,%cr0
[f761f1eb]50 jmp 0f
510:
52 ret
53
[da585a52]54
55## Enable local APIC
56#
57# Enable local APIC in MSR.
58#
[f761f1eb]59enable_l_apic_in_msr:
[24bd23a]60 push %eax
61
[f761f1eb]62 movl $0x1b, %ecx
63 rdmsr
64 orl $(1<<11),%eax
65 orl $(0xfee00000),%eax
66 wrmsr
[24bd23a]67
68 pop %eax
[f761f1eb]69 ret
70
[da585a52]71
72## Declare interrupt handlers
73#
74# Declare interrupt handlers for n interrupt
75# vectors starting at vector i.
76#
77# The handlers setup data segment registers
[fcfac420]78# and call exc_dispatch().
[da585a52]79#
[f761f1eb]80.macro handler i n
81 push %ebp
82 movl %esp,%ebp
83 pusha
[f07bba5]84
85 push %ds
86 push %es
[76cec1e]87
[f761f1eb]88 # we must fill the data segment registers
89 movw $16,%ax
90 movw %ax,%ds
91 movw %ax,%es
[76cec1e]92
[f761f1eb]93 movl $(\i),%edi
94 pushl %ebp
95 addl $4,(%esp)
96 pushl %edi
[fcfac420]97 call exc_dispatch
[f761f1eb]98 addl $8,%esp
99
[f07bba5]100 pop %es
101 pop %ds
102
[76857d1]103
[c192134]104# CLNT
[24bd23a]105 pushfl
106 pop %eax
107 and $0xFFFFBFFF,%eax
108 push %eax
109 popfl
[c192134]110
111
112
[76857d1]113# Test if this is interrupt with error word or not
[24bd23a]114 mov $\i,%cl
115 movl $1,%eax
116 test $0xe0,%cl
117 jnz 0f
118 and $0x1f,%cl
119 shl %cl,%eax
120 and $ERROR_WORD_INTERRUPT_LIST,%eax
121 jz 0f
[59532eb]122
[76857d1]123
124# Return with error word
[24bd23a]125 popa
126 pop %ebp
127 add $4,%esp # Skip error word
128 iret
[59532eb]129
1300:
[76857d1]131# Return with no error word
[f761f1eb]132 popa
133 pop %ebp
[76cec1e]134 iret
135
[f761f1eb]136 .if (\n-\i)-1
137 handler "(\i+1)",\n
138 .endif
139.endm
140
141# keep in sync with pm.h !!!
142IDT_ITEMS=64
143interrupt_handlers:
144h_start:
145 handler 0 64
146# handler 64 128
147# handler 128 192
148# handler 192 256
149h_end:
150
151.data
152.global interrupt_handler_size
153
154interrupt_handler_size: .long (h_end-h_start)/IDT_ITEMS
Note: See TracBrowser for help on using the repository browser.