Changeset 5f70118 in mainline for kernel/arch/ia32


Ignore:
Timestamp:
2010-01-10T12:16:59Z (16 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c77a64f
Parents:
309ede1 (diff), 1ac3a52 (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.
Message:

Merge mainline changes.

Location:
kernel/arch/ia32
Files:
1 added
17 edited
1 moved

Legend:

Unmodified
Added
Removed
  • kernel/arch/ia32/Makefile.inc

    r309ede1 r5f70118  
    3434BFD = binary
    3535TARGET = i686-pc-linux-gnu
     36CLANG_ARCH = i386
    3637TOOLCHAIN_DIR = $(CROSS_PREFIX)/ia32
    3738
     
    4344ICC_CFLAGS += $(CMN1)
    4445SUNCC_CFLAGS += $(CMN1)
     46CLANG_CFLAGS += $(CMN1)
    4547
    4648## Accepted CPUs
     
    7173GCC_CFLAGS += $(CMN2)
    7274ICC_CFLAGS += $(CMN2)
     75CLANG_CFLAGS += $(CMN2)
    7376
    7477ARCH_SOURCES = \
    7578        arch/$(KARCH)/src/context.S \
    7679        arch/$(KARCH)/src/debug/panic.s \
     80        arch/$(KARCH)/src/debug/stacktrace.c \
     81        arch/$(KARCH)/src/debug/stacktrace_asm.S \
    7782        arch/$(KARCH)/src/delay.s \
    7883        arch/$(KARCH)/src/asm.S \
  • kernel/arch/ia32/_link.ld.in

    r309ede1 r5f70118  
    4242                hardcoded_unmapped_kdata_size = .;
    4343                LONG(unmapped_kdata_end - unmapped_kdata_start);
     44                . = ALIGN(8);
    4445                symbol_table = .;
    4546                *(symtab.*);            /* Symbol table, must be LAST symbol! */
  • kernel/arch/ia32/include/context.h

    r309ede1 r5f70118  
    4949#define SP_DELTA        (8 + STACK_ITEM_SIZE)
    5050
     51#define context_set(c, _pc, stack, size) \
     52        do { \
     53                (c)->pc = (uintptr_t) (_pc); \
     54                (c)->sp = ((uintptr_t) (stack)) + (size) - SP_DELTA; \
     55                (c)->ebp = 0; \
     56        } while (0)
     57
    5158#endif /* KERNEL */
    5259
  • kernel/arch/ia32/include/cpu.h

    r309ede1 r5f70118  
    5050#include <arch/pm.h>
    5151#include <arch/asm.h>
     52#include <arch/cpuid.h>
    5253
    5354typedef struct {
     
    5657        unsigned int model;
    5758        unsigned int stepping;
     59        cpuid_feature_info fi;
     60
    5861        tss_t *tss;
    5962       
  • kernel/arch/ia32/include/cpuid.h

    r309ede1 r5f70118  
    6363
    6464struct __cpuid_feature_info {
    65         unsigned                        : 23;
     65        unsigned      : 11;
     66        unsigned sep  :  1;
     67        unsigned      : 11;
    6668        unsigned mmx  :  1;
    6769        unsigned fxsr :  1;
  • kernel/arch/ia32/include/interrupt.h

    r309ede1 r5f70118  
    6969#define VECTOR_DEBUG_IPI                (IVT_FREEBASE + 2)
    7070
    71 typedef struct {
     71typedef struct istate {
    7272        uint32_t eax;
    7373        uint32_t ecx;
    7474        uint32_t edx;
     75        uint32_t ebp;
    7576
    7677        uint32_t gs;
     
    102103}
    103104
     105static inline unative_t istate_get_fp(istate_t *istate)
     106{
     107        return istate->ebp;
     108}
     109
    104110extern void (* disable_irqs_function)(uint16_t irqmask);
    105111extern void (* enable_irqs_function)(uint16_t irqmask);
  • kernel/arch/ia32/include/mm/page.h

    r309ede1 r5f70118  
    146146#define PFERR_CODE_RSVD         (1 << 3)       
    147147
    148 static inline int get_pt_flags(pte_t *pt, size_t i)
     148/** Page Table Entry. */
     149typedef struct {
     150        unsigned present : 1;
     151        unsigned writeable : 1;
     152        unsigned uaccessible : 1;
     153        unsigned page_write_through : 1;
     154        unsigned page_cache_disable : 1;
     155        unsigned accessed : 1;
     156        unsigned dirty : 1;
     157        unsigned pat : 1;
     158        unsigned global : 1;
     159        unsigned soft_valid : 1;        /**< Valid content even if the present bit is not set. */
     160        unsigned avl : 2;
     161        unsigned frame_address : 20;
     162} __attribute__ ((packed)) pte_t;
     163
     164static inline unsigned int get_pt_flags(pte_t *pt, size_t i)
    149165{
    150166        pte_t *p = &pt[i];
  • kernel/arch/ia32/include/types.h

    r309ede1 r5f70118  
    8080#define PRIxn "x"       /**< Format for hexadecimal (u)native_t. */
    8181
    82 /** Page Table Entry. */
    83 typedef struct {
    84         unsigned present : 1;
    85         unsigned writeable : 1;
    86         unsigned uaccessible : 1;
    87         unsigned page_write_through : 1;
    88         unsigned page_cache_disable : 1;
    89         unsigned accessed : 1;
    90         unsigned dirty : 1;
    91         unsigned pat : 1;
    92         unsigned global : 1;
    93         unsigned soft_valid : 1;        /**< Valid content even if the present bit is not set. */
    94         unsigned avl : 2;
    95         unsigned frame_address : 20;
    96 } __attribute__ ((packed)) pte_t;
    97 
    9882#endif
    9983
  • kernel/arch/ia32/src/asm.S

    r309ede1 r5f70118  
    269269        pushl %gs
    270270
     271        pushl %ebp
    271272        pushl %edx
    272273        pushl %ecx
     
    278279        movw %ax, %es
    279280
    280         cld
     281        # stop stack traces here
     282        xorl %ebp, %ebp
    281283
    282284        pushl %esp          # *istate
     
    290292        popl %ecx
    291293        popl %edx
     294        popl %ebp
    292295       
    293296        popl %gs
  • kernel/arch/ia32/src/boot/boot.S

    r309ede1 r5f70118  
    8585        pse_supported:
    8686       
    87         bt $(INTEL_SEP), %edx
    88         jc sep_supported
    89        
    90                 movl $sep_msg, %esi
    91                 jmp error_halt
    92        
    93         sep_supported:
    94 
    9587#include "vesa_prot.inc"
    9688
     
    10294        pushl grub_eax
    10395        call arch_pre_main
     96
     97        # Create the first stack frame
     98        pushl $0
     99        movl %esp, %ebp
    104100       
    105101        call main_bsp
     
    225221        .asciz "Page Size Extension not supported. System halted."
    226222
    227 sep_msg:
    228         .asciz "SYSENTER/SYSEXIT not supported. System halted."
  • kernel/arch/ia32/src/cpu/cpu.c

    r309ede1 r5f70118  
    9292void cpu_arch_init(void)
    9393{
    94         cpuid_feature_info fi;
    9594        cpuid_extended_feature_info efi;
    9695        cpu_info_t info;
     
    102101        CPU->fpu_owner = NULL;
    103102       
    104         cpuid(1, &info);
     103        cpuid(INTEL_CPUID_STANDARD, &info);
    105104       
    106         fi.word = info.cpuid_edx;
     105        CPU->arch.fi.word = info.cpuid_edx;
    107106        efi.word = info.cpuid_ecx;
    108107       
    109         if (fi.bits.fxsr)
     108        if (CPU->arch.fi.bits.fxsr)
    110109                fpu_fxsr();
    111110        else
    112111                fpu_fsr();
    113112       
    114         if (fi.bits.sse) {
     113        if (CPU->arch.fi.bits.sse) {
    115114                asm volatile (
    116115                        "mov %%cr4, %[help]\n"
     
    122121        }
    123122       
    124         /* Setup fast SYSENTER/SYSEXIT syscalls */
    125         syscall_setup_cpu();
     123        if (CPU->arch.fi.bits.sep) {
     124                /* Setup fast SYSENTER/SYSEXIT syscalls */
     125                syscall_setup_cpu();
     126        }
    126127}
    127128
     
    132133        CPU->arch.vendor = VendorUnknown;
    133134        if (has_cpuid()) {
    134                 cpuid(0, &info);
     135                cpuid(INTEL_CPUID_LEVEL, &info);
    135136
    136137                /*
     
    150151                        CPU->arch.vendor = VendorIntel;
    151152               
    152                 cpuid(1, &info);
     153                cpuid(INTEL_CPUID_STANDARD, &info);
    153154                CPU->arch.family = (info.cpuid_eax >> 8) & 0x0f;
    154155                CPU->arch.model = (info.cpuid_eax >> 4) & 0x0f;
  • kernel/arch/ia32/src/debug/stacktrace.c

    r309ede1 r5f70118  
    11/*
    2  * Copyright (c) 2006 Josef Cejka
     2 * Copyright (c) 2010 Jakub Jermar
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup libcmips32     
     29/** @addtogroup ia32
    3030 * @{
    3131 */
    3232/** @file
    33  * @ingroup libcmips32eb       
    3433 */
    3534
    36 #ifndef LIBC_mips32_STACKARG_H_
    37 #define LIBC_mips32_STACKARG_H_
     35#include <stacktrace.h>
     36#include <syscall/copy.h>
     37#include <arch/types.h>
     38#include <typedefs.h>
    3839
    39 /* dont allow to define it second time in stdarg.h */
    40 #define __VARARGS_DEFINED
     40#define FRAME_OFFSET_FP_PREV    0
     41#define FRAME_OFFSET_RA         1
    4142
    42 #include <sys/types.h>
     43bool kernel_frame_pointer_validate(uintptr_t fp)
     44{
     45        return fp != 0;
     46}
    4347
    44 /**
    45  * va_arg macro for MIPS32 - problem is that 64 bit values must be aligned on an 8-byte boundary (32bit values not)
    46  * To satisfy this, paddings must be sometimes inserted.
    47  */
     48bool kernel_frame_pointer_prev(uintptr_t fp, uintptr_t *prev)
     49{
     50        uint32_t *stack = (void *) fp;
     51        *prev = stack[FRAME_OFFSET_FP_PREV];
     52        return true;
     53}
    4854
    49 typedef uint8_t* va_list;
     55bool kernel_return_address_get(uintptr_t fp, uintptr_t *ra)
     56{
     57        uint32_t *stack = (void *) fp;
     58        *ra = stack[FRAME_OFFSET_RA];
     59        return true;
     60}
    5061
    51 #define va_start(ap, lst) \
    52         ((ap) = (va_list)&(lst) + sizeof(lst))
     62bool uspace_frame_pointer_validate(uintptr_t fp)
     63{
     64        return fp != 0;
     65}
    5366
    54 #define va_arg(ap, type)        \
    55         (((type *)((ap) = (va_list)( (sizeof(type) <= 4) ? ((uint32_t)((ap) + 2*4 - 1) & (~3)) : ((uint32_t)((ap) + 2*8 -1) & (~7)) )))[-1])
     67bool uspace_frame_pointer_prev(uintptr_t fp, uintptr_t *prev)
     68{
     69        return !copy_from_uspace((void *) prev,
     70            (uint32_t *) fp + FRAME_OFFSET_FP_PREV, sizeof(*prev));
     71}
    5672
    57 #define va_end(ap)
    58 
    59 #endif
     73bool uspace_return_address_get(uintptr_t fp, uintptr_t *ra)
     74{
     75        return !copy_from_uspace((void *) ra, (uint32_t *) fp + FRAME_OFFSET_RA,
     76            sizeof(*ra));
     77}
    6078
    6179/** @}
  • kernel/arch/ia32/src/ia32.c

    r309ede1 r5f70118  
    6868#include <sysinfo/sysinfo.h>
    6969#include <arch/boot/boot.h>
     70#include <memstr.h>
    7071
    7172#ifdef CONFIG_SMP
     
    169170                        i8042_wire(i8042_instance, kbrd);
    170171                        trap_virtual_enable_irqs(1 << IRQ_KBD);
     172                        trap_virtual_enable_irqs(1 << IRQ_MOUSE);
    171173                }
    172174        }
     
    176178         * self-sufficient.
    177179         */
    178         sysinfo_set_item_val("kbd", NULL, true);
    179         sysinfo_set_item_val("kbd.inr", NULL, IRQ_KBD);
    180         sysinfo_set_item_val("kbd.address.physical", NULL,
     180        sysinfo_set_item_val("i8042", NULL, true);
     181        sysinfo_set_item_val("i8042.inr_a", NULL, IRQ_KBD);
     182        sysinfo_set_item_val("i8042.inr_b", NULL, IRQ_MOUSE);
     183        sysinfo_set_item_val("i8042.address.physical", NULL,
    181184            (uintptr_t) I8042_BASE);
    182         sysinfo_set_item_val("kbd.address.kernel", NULL,
     185        sysinfo_set_item_val("i8042.address.kernel", NULL,
    183186            (uintptr_t) I8042_BASE);
    184187#endif
  • kernel/arch/ia32/src/interrupt.c

    r309ede1 r5f70118  
    5353#include <ddi/irq.h>
    5454#include <symtab.h>
     55#include <stacktrace.h>
    5556
    5657/*
     
    7980        printf("stack: %#lx, %#lx, %#lx, %#lx\n", istate->stack[0], istate->stack[1], istate->stack[2], istate->stack[3]);
    8081        printf("       %#lx, %#lx, %#lx, %#lx\n", istate->stack[4], istate->stack[5], istate->stack[6], istate->stack[7]);
     82
     83        stack_trace_istate(istate);
    8184}
    8285
     
    9699        decode_istate(istate);
    97100        panic("Unserviced interrupt: %d.", n);
     101}
     102
     103static void de_fault(int n, istate_t *istate)
     104{
     105        fault_if_from_uspace(istate, "Divide error.");
     106
     107        decode_istate(istate);
     108        panic("Divide error.");
    98109}
    99110
     
    215226        }
    216227       
     228        exc_register(0, "de_fault", (iroutine) de_fault);
    217229        exc_register(7, "nm_fault", (iroutine) nm_fault);
    218230        exc_register(12, "ss_fault", (iroutine) ss_fault);
  • kernel/arch/ia32/src/mm/page.c

    r309ede1 r5f70118  
    8080{
    8181        if (last_frame + ALIGN_UP(size, PAGE_SIZE) > KA2PA(KERNEL_ADDRESS_SPACE_END_ARCH))
    82                 panic("Unable to map physical memory %p (%d bytes).", physaddr, size)
     82                panic("Unable to map physical memory %p (%d bytes).", physaddr, size);
    8383       
    8484        uintptr_t virtaddr = PA2KA(last_frame);
  • kernel/arch/ia32/src/proc/scheduler.c

    r309ede1 r5f70118  
    6161            SP_DELTA];
    6262       
    63         /* Set kernel stack for CP3 -> CPL0 switch via SYSENTER */
    64         write_msr(IA32_MSR_SYSENTER_ESP, kstk);
     63        if (CPU->arch.fi.bits.sep) {
     64                /* Set kernel stack for CP3 -> CPL0 switch via SYSENTER */
     65                write_msr(IA32_MSR_SYSENTER_ESP, kstk);
     66        }
    6567       
    6668        /* Set kernel stack for CPL3 -> CPL0 switch via interrupt */
  • kernel/arch/ia32/src/smp/ap.S

    r309ede1 r5f70118  
    7878        addl $0x80000000, %esp                  # PA2KA(ctx.sp)
    7979       
     80        pushl $0                                # create the first stack frame
     81        movl %esp, %ebp
     82
    8083        jmpl $KTEXT, $main_ap
    8184
  • kernel/arch/ia32/src/userspace.c

    r309ede1 r5f70118  
    7070                "movl %[uarg], %%eax\n"
    7171               
    72                 /* %ebx is defined to hold pcb_ptr - set it to 0 */
    73                 "xorl %%ebx, %%ebx\n"
     72                /* %edi is defined to hold pcb_ptr - set it to 0 */
     73                "xorl %%edi, %%edi\n"
    7474               
    7575                "iret\n"
Note: See TracChangeset for help on using the changeset viewer.