Changeset da585a52 in mainline
- Timestamp:
- 2005-05-11T18:58:54Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d7568a9f
- Parents:
- 93ca46f
- Location:
- arch/ia32
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
arch/ia32/_link.ld
r93ca46f rda585a52 1 /* 2 * ia32 linker script 1 /** IA-32 linker script 3 2 * 4 3 * kernel text -
arch/ia32/src/asm.s
r93ca46f rda585a52 27 27 # 28 28 29 # very low and hardware-level functions29 ## very low and hardware-level functions 30 30 31 31 .text … … 54 54 .global memcmp 55 55 56 # 57 # set priority level high 56 57 ## Set priority level high 58 # 59 # Disable interrupts and return previous 60 # EFLAGS in EAX. 61 # 58 62 cpu_priority_high: 59 63 pushf … … 61 65 cli 62 66 ret 63 64 # 65 # set priority level low 67 68 69 ## Set priority level low 70 # 71 # Enable interrupts and return previous 72 # EFLAGS in EAX. 73 # 66 74 cpu_priority_low: 67 75 pushf … … 70 78 ret 71 79 72 # 73 # restore priority level 80 81 ## Restore priority level 82 # 83 # Restore EFLAGS. 84 # 74 85 cpu_priority_restore: 75 86 push 4(%esp) … … 77 88 ret 78 89 79 # return raw priority level 90 ## Return raw priority level 91 # 92 # Return EFLAFS in EAX. 93 # 80 94 cpu_priority_read: 81 95 pushf … … 83 97 ret 84 98 99 100 ## Halt the CPU 101 # 102 # Halt the CPU using HLT. 103 # 85 104 cpu_halt: 86 105 cpu_sleep: … … 88 107 ret 89 108 109 110 ## Turn paging on 111 # 112 # Enable paging and write-back caching in CR0. 113 # 90 114 paging_on: 91 115 pushl %eax … … 99 123 ret 100 124 125 126 ## Read CR3 127 # 128 # Store CR3 in EAX. 129 # 101 130 cpu_read_dba: 102 131 movl %cr3,%eax 103 132 ret 104 133 134 135 ## Write CR3 136 # 137 # Set CR3. 138 # 105 139 cpu_write_dba: 106 140 pushl %eax … … 110 144 ret 111 145 146 147 ## Read CR2 148 # 149 # Store CR2 in EAX. 150 # 112 151 cpu_read_cr2: 113 152 movl %cr2,%eax 114 153 ret 115 154 155 156 ## Enable local APIC 157 # 158 # Enable local APIC in MSR. 159 # 116 160 enable_l_apic_in_msr: 117 161 pusha … … 126 170 ret 127 171 172 173 ## Declare interrupt handlers 174 # 175 # Declare interrupt handlers for n interrupt 176 # vectors starting at vector i. 177 # 178 # The handlers setup data segment registers 179 # and call trap_dispatcher(). 180 # 128 181 .macro handler i n 129 182 push %ebp … … 170 223 171 224 225 ## I/O input (byte) 226 # 227 # Get a byte from I/O port and store it AL. 228 # 172 229 inb: 173 230 push %edx … … 178 235 ret 179 236 237 238 ## I/O input (word) 239 # 240 # Get a word from I/O port and store it AX. 241 # 180 242 inw: 181 243 push %edx … … 186 248 ret 187 249 250 251 ## I/O input (dword) 252 # 253 # Get a dword from I/O port and store it EAX. 254 # 188 255 inl: 189 256 push %edx … … 194 261 ret 195 262 263 264 ## I/O output (byte) 265 # 266 # Send a byte to I/O port. 267 # 196 268 outb: 197 269 push %ebp … … 207 279 ret 208 280 281 282 ## I/O output (word) 283 # 284 # Send a word to I/O port. 285 # 209 286 outw: 210 287 push %ebp … … 220 297 ret 221 298 299 300 ## I/O output (dword) 301 # 302 # Send a dword to I/O port. 303 # 222 304 outl: 223 305 push %ebp … … 233 315 ret 234 316 317 318 ## Copy memory 319 # 320 # Copy a given number of bytes (3rd argument) 321 # from the memory location defined by 1st argument 322 # to the memory location defined by 2nd argument. 323 # The memory areas cannot overlap. 324 # 235 325 SRC=8 236 326 DST=12 … … 252 342 ret 253 343 344 345 ## Fill memory with bytes 346 # 347 # Fill a given number of bytes (2nd argument) 348 # at memory defined by 1st argument with the 349 # byte value defined by 3rd argument. 350 # 351 DST=8 352 CNT=12 353 X=16 354 memsetb: 355 push %ebp 356 movl %esp,%ebp 357 pusha 358 359 cld 360 movl CNT(%ebp),%ecx 361 movl DST(%ebp),%edi 362 movl X(%ebp),%eax 363 364 rep stosb %al,%es:(%edi) 365 366 popa 367 pop %ebp 368 ret 369 370 371 ## Fill memory with words 372 # 373 # Fill a given number of words (2nd argument) 374 # at memory defined by 1st argument with the 375 # word value defined by 3rd argument. 376 # 254 377 DST=8 255 378 CNT=12 … … 271 394 ret 272 395 273 DST=8 274 CNT=12 275 X=16 276 memsetb: 277 push %ebp 278 movl %esp,%ebp 279 pusha 280 281 cld 282 movl CNT(%ebp),%ecx 283 movl DST(%ebp),%edi 284 movl X(%ebp),%eax 285 286 rep stosb %al,%es:(%edi) 287 288 popa 289 pop %ebp 290 ret 291 396 397 ## Compare memory regions for equality 398 # 399 # Compare a given number of bytes (3rd argument) 400 # at memory locations defined by 1st and 2nd argument 401 # for equality. If the bytes are equal, EAX contains 402 # 0. 403 # 292 404 SRC=12 293 405 DST=16 -
arch/ia32/src/context.s
r93ca46f rda585a52 36 36 .global fpu_lazy_context_restore 37 37 38 39 ## Save current CPU context 38 40 # 39 # save context of this CPU 41 # Save CPU context to the kernel_context variable 42 # pointed by the 1st argument. Returns 1 in EAX. 43 # 40 44 context_save: 41 45 push %ebx … … 59 63 incl %eax 60 64 ret 61 65 66 67 ## Restore current CPU context 62 68 # 63 # restore saved context on this CPU 69 # Restore CPU context from the kernel_context variable 70 # pointed by the 1st argument. Returns 0 in EAX. 71 # 64 72 context_restore: 65 73 movl 4(%esp),%eax # address of the kernel_context variable to restore context from … … 78 86 xorl %eax,%eax # context_restore returns 0 79 87 ret 80 81 -
arch/ia32/src/cpuid.s
r93ca46f rda585a52 27 27 # 28 28 29 #30 # CPU identification functions.31 29 # The code below just interfaces the CPUID instruction. 32 30 # CPU recognition logic is contained in higher-level functions. … … 38 36 .global rdtsc 39 37 38 39 ## Determine CPUID support 40 # 41 # Return 0 in EAX if CPUID is not support, 1 if supported. 42 # 40 43 has_cpuid: 41 44 push %ebx … … 56 59 ret 57 60 58 # cpuid(__u32 cmd, struct cpu_info *info) 61 62 ## Get CPUID data 63 # 64 # This code is just an interfaces the CPUID instruction, CPU recognition 65 # logic is contained in higher-level functions. 66 # 67 # The C prototype is: 68 # void cpuid(__u32 cmd, struct cpu_info *info) 69 # 70 # @param cmd CPUID command. 71 # @param info Buffer to store CPUID output. 72 # 59 73 cpuid: 60 74 pushl %ebp -
arch/ia32/src/userspace.c
r93ca46f rda585a52 34 34 #include <mm/vm.h> 35 35 36 37 /** Enter userspace 38 * 39 * Change CPU protection level to 3, enter userspace. 40 * 41 */ 36 42 void userspace(void) 37 43 { … … 48 54 "iret" 49 55 : : "i" (selector(UDATA_DES) | PL_USER), "i" (USTACK_ADDRESS+THREAD_STACK_SIZE-1000), "r" (pri), "i" (selector(UTEXT_DES) | PL_USER), "i" (UTEXT_ADDRESS)); 50 /* NOT REACHED */51 56 57 /* Unreachable */ 52 58 for(;;); 53 59 }
Note:
See TracChangeset
for help on using the changeset viewer.