Changeset 6b1a85c in mainline
- Timestamp:
- 2010-07-13T21:54:38Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 4003861
- Parents:
- 5f83634 (diff), c0e9f3f (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- kernel
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/amd64/include/cpu.h
r5f83634 r6b1a85c 45 45 #define RFLAGS_DF (1 << 10) 46 46 #define RFLAGS_OF (1 << 11) 47 #define RFLAGS_NT (1 << 14) 47 48 #define RFLAGS_RF (1 << 16) 48 49 -
kernel/arch/amd64/include/interrupt.h
r5f83634 r6b1a85c 74 74 typedef struct istate { 75 75 uint64_t rax; 76 uint64_t rbx; 76 77 uint64_t rcx; 77 78 uint64_t rdx; 78 79 uint64_t rsi; 79 80 uint64_t rdi; 81 uint64_t rbp; 80 82 uint64_t r8; 81 83 uint64_t r9; 82 84 uint64_t r10; 83 85 uint64_t r11; 84 uint64_t rbp; 85 uint64_t error_word; 86 uint64_t r12; 87 uint64_t r13; 88 uint64_t r14; 89 uint64_t r15; 90 uint64_t alignment; /* align rbp_frame on multiple of 16 */ 91 uint64_t rbp_frame; /* imitation of frame pointer linkage */ 92 uint64_t rip_frame; /* imitation of return address linkage */ 93 uint64_t error_word; /* real or fake error word */ 86 94 uint64_t rip; 87 95 uint64_t cs; 88 96 uint64_t rflags; 89 uint64_t stack[]; /* Additional data on stack */ 97 uint64_t rsp; /* only if istate_t is from uspace */ 98 uint64_t ss; /* only if istate_t is from uspace */ 90 99 } istate_t; 91 100 -
kernel/arch/amd64/src/asm.S
r5f83634 r6b1a85c 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 29 #define IREGISTER_SPACE 8030 31 #define IOFFSET_RAX 0x0032 #define IOFFSET_RCX 0x0833 #define IOFFSET_RDX 0x1034 #define IOFFSET_RSI 0x1835 #define IOFFSET_RDI 0x2036 #define IOFFSET_R8 0x2837 #define IOFFSET_R9 0x3038 #define IOFFSET_R10 0x3839 #define IOFFSET_R11 0x4040 #define IOFFSET_RBP 0x4841 42 /**43 * Mask for interrupts 0 - 31 (bits 0 - 31) where 0 means that int44 * has no error word and 1 means interrupt with error word45 *46 */47 #define ERROR_WORD_INTERRUPT_LIST 0x00027D0048 28 49 29 #include <arch/pm.h> … … 174 154 ret 175 155 176 /** Push all volatile general purpose registers on stack 177 * 178 */ 179 .macro save_all_gpr 180 movq %rax, IOFFSET_RAX(%rsp) 181 movq %rcx, IOFFSET_RCX(%rsp) 182 movq %rdx, IOFFSET_RDX(%rsp) 183 movq %rsi, IOFFSET_RSI(%rsp) 184 movq %rdi, IOFFSET_RDI(%rsp) 185 movq %r8, IOFFSET_R8(%rsp) 186 movq %r9, IOFFSET_R9(%rsp) 187 movq %r10, IOFFSET_R10(%rsp) 188 movq %r11, IOFFSET_R11(%rsp) 189 movq %rbp, IOFFSET_RBP(%rsp) 190 .endm 191 192 .macro restore_all_gpr 193 movq IOFFSET_RAX(%rsp), %rax 194 movq IOFFSET_RCX(%rsp), %rcx 195 movq IOFFSET_RDX(%rsp), %rdx 196 movq IOFFSET_RSI(%rsp), %rsi 197 movq IOFFSET_RDI(%rsp), %rdi 198 movq IOFFSET_R8(%rsp), %r8 199 movq IOFFSET_R9(%rsp), %r9 200 movq IOFFSET_R10(%rsp), %r10 201 movq IOFFSET_R11(%rsp), %r11 202 movq IOFFSET_RBP(%rsp), %rbp 203 .endm 204 205 #define INTERRUPT_ALIGN 128 156 #define ISTATE_OFFSET_RAX 0 157 #define ISTATE_OFFSET_RBX 8 158 #define ISTATE_OFFSET_RCX 16 159 #define ISTATE_OFFSET_RDX 24 160 #define ISTATE_OFFSET_RSI 32 161 #define ISTATE_OFFSET_RDI 40 162 #define ISTATE_OFFSET_RBP 48 163 #define ISTATE_OFFSET_R8 56 164 #define ISTATE_OFFSET_R9 64 165 #define ISTATE_OFFSET_R10 72 166 #define ISTATE_OFFSET_R11 80 167 #define ISTATE_OFFSET_R12 88 168 #define ISTATE_OFFSET_R13 96 169 #define ISTATE_OFFSET_R14 104 170 #define ISTATE_OFFSET_R15 112 171 #define ISTATE_OFFSET_ALIGNMENT 120 172 #define ISTATE_OFFSET_RBP_FRAME 128 173 #define ISTATE_OFFSET_RIP_FRAME 136 174 #define ISTATE_OFFSET_ERROR_WORD 144 175 #define ISTATE_OFFSET_RIP 152 176 #define ISTATE_OFFSET_CS 160 177 #define ISTATE_OFFSET_RFLAGS 168 178 #define ISTATE_OFFSET_RSP 176 179 #define ISTATE_OFFSET_SS 184 180 181 /* 182 * Size of the istate structure without the hardware-saved part and without the 183 * error word. 184 */ 185 #define ISTATE_SOFT_SIZE 144 186 187 /** 188 * Mask for interrupts 0 - 31 (bits 0 - 31) where 0 means that int 189 * has no error word and 1 means interrupt with error word 190 * 191 */ 192 #define ERROR_WORD_INTERRUPT_LIST 0x00027D00 193 194 #define INTERRUPT_ALIGN 256 206 195 207 196 /** Declare interrupt handlers … … 229 218 * Version with error word. 230 219 */ 231 subq $I REGISTER_SPACE, %rsp220 subq $ISTATE_SOFT_SIZE, %rsp 232 221 .else 233 222 /* 234 * Version without error word ,223 * Version without error word. 235 224 */ 236 subq $(I REGISTER_SPACE + 8), %rsp225 subq $(ISTATE_SOFT_SIZE + 8), %rsp 237 226 .endif 238 227 .else 239 228 /* 240 * Version without error word ,229 * Version without error word. 241 230 */ 242 subq $(I REGISTER_SPACE + 8), %rsp231 subq $(ISTATE_SOFT_SIZE + 8), %rsp 243 232 .endif 244 233 245 save_all_gpr246 cld247 248 234 /* 235 * Save the general purpose registers. 236 */ 237 movq %rax, ISTATE_OFFSET_RAX(%rsp) 238 movq %rbx, ISTATE_OFFSET_RBX(%rsp) 239 movq %rcx, ISTATE_OFFSET_RCX(%rsp) 240 movq %rdx, ISTATE_OFFSET_RDX(%rsp) 241 movq %rsi, ISTATE_OFFSET_RSI(%rsp) 242 movq %rdi, ISTATE_OFFSET_RDI(%rsp) 243 movq %rbp, ISTATE_OFFSET_RBP(%rsp) 244 movq %r8, ISTATE_OFFSET_R8(%rsp) 245 movq %r9, ISTATE_OFFSET_R9(%rsp) 246 movq %r10, ISTATE_OFFSET_R10(%rsp) 247 movq %r11, ISTATE_OFFSET_R11(%rsp) 248 movq %r12, ISTATE_OFFSET_R12(%rsp) 249 movq %r13, ISTATE_OFFSET_R13(%rsp) 250 movq %r14, ISTATE_OFFSET_R14(%rsp) 251 movq %r15, ISTATE_OFFSET_R15(%rsp) 252 253 /* 254 * Imitate a regular stack frame linkage. 249 255 * Stop stack traces here if we came from userspace. 250 256 */ 251 movq %cs, %rax252 257 xorq %rdx, %rdx 253 cmpq %rax, IREGISTER_SPACE+16(%rsp) 254 cmovneq %rdx, %rbp 255 256 movq $(\i), %rdi /* %rdi - first argument */ 257 movq %rsp, %rsi /* %rsi - pointer to istate */ 258 258 cmpq $(gdtselector(KTEXT_DES)), ISTATE_OFFSET_CS(%rsp) 259 cmovnzq %rdx, %rbp 260 261 movq %rbp, ISTATE_OFFSET_RBP_FRAME(%rsp) 262 movq ISTATE_OFFSET_RIP(%rsp), %rax 263 movq %rax, ISTATE_OFFSET_RIP_FRAME(%rsp) 264 leaq ISTATE_OFFSET_RBP_FRAME(%rsp), %rbp 265 266 movq $(\i), %rdi /* pass intnum in the first argument */ 267 movq %rsp, %rsi /* pass istate address in the second argument */ 268 269 cld 270 259 271 /* Call exc_dispatch(i, istate) */ 260 272 call exc_dispatch 261 262 restore_all_gpr 273 274 /* 275 * Restore all scratch registers and the preserved registers we have 276 * clobbered in this handler (i.e. RBP). 277 */ 278 movq ISTATE_OFFSET_RAX(%rsp), %rax 279 movq ISTATE_OFFSET_RCX(%rsp), %rcx 280 movq ISTATE_OFFSET_RDX(%rsp), %rdx 281 movq ISTATE_OFFSET_RSI(%rsp), %rsi 282 movq ISTATE_OFFSET_RDI(%rsp), %rdi 283 movq ISTATE_OFFSET_RBP(%rsp), %rbp 284 movq ISTATE_OFFSET_R8(%rsp), %r8 285 movq ISTATE_OFFSET_R9(%rsp), %r9 286 movq ISTATE_OFFSET_R10(%rsp), %r10 287 movq ISTATE_OFFSET_R11(%rsp), %r11 263 288 264 289 /* $8 = Skip error word */ 265 addq $(I REGISTER_SPACE + 8), %rsp290 addq $(ISTATE_SOFT_SIZE + 8), %rsp 266 291 iretq 267 292 -
kernel/arch/amd64/src/syscall.c
r5f83634 r6b1a85c 66 66 * - clear DF so that the string instructions operate in 67 67 * the right direction 68 * - clear NT to prevent a #GP should the flag proliferate to an IRET 68 69 */ 69 write_msr(AMD_MSR_SFMASK, RFLAGS_IF | RFLAGS_DF );70 write_msr(AMD_MSR_SFMASK, RFLAGS_IF | RFLAGS_DF | RFLAGS_NT); 70 71 } 71 72 -
kernel/arch/ia32/include/cpu.h
r5f83634 r6b1a85c 37 37 38 38 #define EFLAGS_IF (1 << 9) 39 #define EFLAGS_DF (1 << 10) 40 #define EFLAGS_NT (1 << 14) 39 41 #define EFLAGS_RF (1 << 16) 40 42 -
kernel/arch/ia32/src/asm.S
r5f83634 r6b1a85c 1 1 /* 2 * Copyright (c) 20 01Jakub Jermar2 * Copyright (c) 2010 Jakub Jermar 3 3 * All rights reserved. 4 4 * … … 32 32 33 33 #include <arch/pm.h> 34 #include <arch/cpu.h> 34 35 #include <arch/mm/page.h> 35 36 … … 190 191 .global sysenter_handler 191 192 sysenter_handler: 192 sti193 193 subl $(ISTATE_REAL_SIZE), %esp 194 194 … … 227 227 * Switch to kernel selectors. 228 228 */ 229 movw $ 16, %ax229 movw $(gdtselector(KDATA_DES)), %ax 230 230 movw %ax, %ds 231 231 movw %ax, %es 232 232 233 cld 233 /* 234 * Sanitize EFLAGS. 235 * 236 * SYSENTER does not clear the NT flag, which could thus proliferate 237 * from here to the IRET instruction via a context switch and result 238 * in crash. 239 * 240 * SYSENTER does not clear DF, which the ABI assumes to be cleared. 241 * 242 * SYSENTER clears IF, which we would like to be set for syscalls. 243 * 244 */ 245 pushl $(EFLAGS_IF) /* specify EFLAGS bits that we want to set */ 246 popfl /* set bits from the mask, clear or ignore others */ 247 234 248 call syscall_handler 235 249 … … 294 308 * Switch to kernel selectors. 295 309 */ 296 movl $ 16, %eax310 movl $(gdtselector(KDATA_DES)), %eax 297 311 movl %eax, %ds 298 312 movl %eax, %es … … 358 372 .if (1 << \i) & ERROR_WORD_INTERRUPT_LIST 359 373 /* 360 * Exception with error word : do nothing374 * Exception with error word. 361 375 */ 376 subl $ISTATE_SOFT_SIZE, %esp 362 377 .else 363 378 /* 364 379 * Exception without error word: fake up one 365 380 */ 366 pushl $0381 subl $(ISTATE_SOFT_SIZE + 4), %esp 367 382 .endif 368 383 .else 369 384 /* 370 * Interrupt: fake up one385 * Interrupt: fake up an error word 371 386 */ 372 pushl $0387 subl $(ISTATE_SOFT_SIZE + 4), %esp 373 388 .endif 374 375 subl $ISTATE_SOFT_SIZE, %esp376 389 377 390 /* … … 404 417 * Switch to kernel selectors. 405 418 */ 406 movl $ 16, %eax419 movl $(gdtselector(KDATA_DES)), %eax 407 420 movl %eax, %ds 408 421 movl %eax, %es … … 413 426 */ 414 427 xorl %eax, %eax 415 cmpl $ 8, ISTATE_OFFSET_CS(%esp)416 cmov l %eax, %ebp428 cmpl $(gdtselector(KTEXT_DES)), ISTATE_OFFSET_CS(%esp) 429 cmovnzl %eax, %ebp 417 430 418 431 movl %ebp, ISTATE_OFFSET_EBP_FRAME(%esp) -
kernel/generic/src/console/kconsole.c
r5f83634 r6b1a85c 210 210 link_t *pos = NULL; 211 211 const char *hint; 212 char output[MAX_CMDLINE];212 char *output = malloc(MAX_CMDLINE, 0); 213 213 214 214 output[0] = 0; … … 235 235 str_cpy(input, size, output); 236 236 237 free(output); 237 238 return found; 238 239 } … … 245 246 wchar_t *current = history[history_pos]; 246 247 current[0] = 0; 248 char *tmp = malloc(STR_BOUNDS(MAX_CMDLINE), 0); 247 249 248 250 while (true) { … … 289 291 beg++; 290 292 291 char tmp[STR_BOUNDS(MAX_CMDLINE)];292 293 wstr_to_str(tmp, position - beg + 1, current + beg); 293 294 … … 415 416 } 416 417 418 free(tmp); 417 419 return current; 418 420 } … … 630 632 cmd->argv[i].vartype = ARG_TYPE_STRING; 631 633 } else { 632 printf("Wrong syn xtax.\n");634 printf("Wrong syntax.\n"); 633 635 error = true; 634 636 } … … 688 690 printf("Type \"exit\" to leave the console.\n"); 689 691 692 char *cmdline = malloc(STR_BOUNDS(MAX_CMDLINE), 0); 690 693 while (true) { 691 694 wchar_t *tmp = clever_readline((char *) prompt, stdin); … … 694 697 continue; 695 698 696 char cmdline[STR_BOUNDS(MAX_CMDLINE)];697 699 wstr_to_str(cmdline, STR_BOUNDS(MAX_CMDLINE), tmp); 698 700 … … 706 708 (void) cmd_info->func(cmd_info->argv); 707 709 } 710 free(cmdline); 708 711 } 709 712
Note:
See TracChangeset
for help on using the changeset viewer.