Changeset 5f70118 in mainline for kernel/arch


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
Files:
12 added
2 deleted
70 edited
4 moved

Legend:

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

    r309ede1 r5f70118  
    3434BFD = binary
    3535TARGET = amd64-linux-gnu
     36CLANG_ARCH = x86_64
    3637TOOLCHAIN_DIR = $(CROSS_PREFIX)/amd64
    3738
    3839FPU_NO_CFLAGS = -mno-sse -mno-sse2
    39 CMN1 = -m64 -mcmodel=kernel -mno-red-zone -fno-unwind-tables
     40CMN1 = -m64 -mcmodel=kernel -mno-red-zone -fno-unwind-tables -fno-omit-frame-pointer
    4041GCC_CFLAGS += $(CMN1)
    4142ICC_CFLAGS += $(CMN1)
     
    5960        arch/$(KARCH)/src/boot/boot.S \
    6061        arch/$(KARCH)/src/boot/memmap.c \
     62        arch/$(KARCH)/src/debug/stacktrace.c \
     63        arch/$(KARCH)/src/debug/stacktrace_asm.S \
    6164        arch/$(KARCH)/src/pm.c \
    6265        arch/$(KARCH)/src/context.S \
  • kernel/arch/amd64/_link.ld.in

    r309ede1 r5f70118  
    4444                *(COMMON);              /* global variables */
    4545
     46                . = ALIGN(8);
    4647                symbol_table = .;
    4748                *(symtab.*);            /* Symbol table, must be LAST symbol!*/
  • kernel/arch/amd64/include/context.h

    r309ede1 r5f70118  
    4646#define SP_DELTA     16
    4747
     48#define context_set(c, _pc, stack, size) \
     49        do { \
     50                (c)->pc = (uintptr_t) (_pc); \
     51                (c)->sp = ((uintptr_t) (stack)) + (size) - SP_DELTA; \
     52                (c)->rbp = 0; \
     53        } while (0)
     54
    4855#endif /* KERNEL */
    4956
  • kernel/arch/amd64/include/interrupt.h

    r309ede1 r5f70118  
    7070
    7171/** This is passed to interrupt handlers */
    72 typedef struct {
     72typedef struct istate {
    7373        uint64_t rax;
    7474        uint64_t rcx;
     
    8080        uint64_t r10;
    8181        uint64_t r11;
     82        uint64_t rbp;
    8283        uint64_t error_word;
    8384        uint64_t rip;
     
    101102        return istate->rip;
    102103}
     104static inline unative_t istate_get_fp(istate_t *istate)
     105{
     106        return istate->rbp;
     107}
    103108
    104109extern void (* disable_irqs_function)(uint16_t irqmask);
  • kernel/arch/amd64/include/mm/page.h

    r309ede1 r5f70118  
    177177#define PFERR_CODE_ID           (1 << 4)
    178178
    179 static inline int get_pt_flags(pte_t *pt, size_t i)
     179/** Page Table Entry. */
     180typedef struct {
     181        unsigned present : 1;
     182        unsigned writeable : 1;
     183        unsigned uaccessible : 1;
     184        unsigned page_write_through : 1;
     185        unsigned page_cache_disable : 1;
     186        unsigned accessed : 1;
     187        unsigned dirty : 1;
     188        unsigned unused: 1;
     189        unsigned global : 1;
     190        unsigned soft_valid : 1;                /**< Valid content even if present bit is cleared. */
     191        unsigned avl : 2;
     192        unsigned addr_12_31 : 30;
     193        unsigned addr_32_51 : 21;
     194        unsigned no_execute : 1;
     195} __attribute__ ((packed)) pte_t;
     196
     197static inline unsigned int get_pt_flags(pte_t *pt, size_t i)
    180198{
    181199        pte_t *p = &pt[i];
  • kernel/arch/amd64/include/types.h

    r309ede1 r5f70118  
    8282#define PRIxn "llx"
    8383
    84 /** Page Table Entry. */
    85 typedef struct {
    86         unsigned present : 1;
    87         unsigned writeable : 1;
    88         unsigned uaccessible : 1;
    89         unsigned page_write_through : 1;
    90         unsigned page_cache_disable : 1;
    91         unsigned accessed : 1;
    92         unsigned dirty : 1;
    93         unsigned unused: 1;
    94         unsigned global : 1;
    95         unsigned soft_valid : 1;                /**< Valid content even if present bit is cleared. */
    96         unsigned avl : 2;
    97         unsigned addr_12_31 : 30;
    98         unsigned addr_32_51 : 21;
    99         unsigned no_execute : 1;
    100 } __attribute__ ((packed)) pte_t;
    101 
    10284#endif
    10385
  • kernel/arch/amd64/src/amd64.c

    r309ede1 r5f70118  
    6767#include <ddi/irq.h>
    6868#include <sysinfo/sysinfo.h>
     69#include <memstr.h>
    6970
    7071/** Disable I/O on non-privileged levels
     
    211212                        i8042_wire(i8042_instance, kbrd);
    212213                        trap_virtual_enable_irqs(1 << IRQ_KBD);
     214                        trap_virtual_enable_irqs(1 << IRQ_MOUSE);
    213215                }
    214216        }
     
    218220         * self-sufficient.
    219221         */
    220         sysinfo_set_item_val("kbd", NULL, true);
    221         sysinfo_set_item_val("kbd.inr", NULL, IRQ_KBD);
    222         sysinfo_set_item_val("kbd.address.physical", NULL,
     222        sysinfo_set_item_val("i8042", NULL, true);
     223        sysinfo_set_item_val("i8042.inr_a", NULL, IRQ_KBD);
     224        sysinfo_set_item_val("i8042.inr_b", NULL, IRQ_MOUSE);
     225        sysinfo_set_item_val("i8042.address.physical", NULL,
    223226            (uintptr_t) I8042_BASE);
    224         sysinfo_set_item_val("kbd.address.kernel", NULL,
     227        sysinfo_set_item_val("i8042.address.kernel", NULL,
    225228            (uintptr_t) I8042_BASE);
    226229#endif
  • kernel/arch/amd64/src/asm_utils.S

    r309ede1 r5f70118  
    2727#
    2828
    29 #define IREGISTER_SPACE 72
     29#define IREGISTER_SPACE 80
    3030
    3131#define IOFFSET_RAX     0x0
     
    3838#define IOFFSET_R10     0x38
    3939#define IOFFSET_R11     0x40
     40#define IOFFSET_RBP     0x48
    4041
    4142#  Mask for interrupts 0 - 31 (bits 0 - 31) where 0 means that int has no error word
     
    179180        movq %r10, IOFFSET_R10(%rsp)
    180181        movq %r11, IOFFSET_R11(%rsp)
     182        movq %rbp, IOFFSET_RBP(%rsp)
    181183.endm
    182184
     
    191193        movq IOFFSET_R10(%rsp), %r10
    192194        movq IOFFSET_R11(%rsp), %r11
     195        movq IOFFSET_RBP(%rsp), %rbp
    193196.endm
    194197
     
    235238        cld
    236239
     240        # Stop stack traces here
     241        xorq %rbp, %rbp
     242
    237243        movq $(\i), %rdi        # %rdi - first parameter
    238244        movq %rsp, %rsi         # %rsi - pointer to istate
  • kernel/arch/amd64/src/boot/boot.S

    r309ede1 r5f70118  
    174174        call arch_pre_main
    175175       
     176        # create the first stack frame
     177        pushq $0
     178        movq %rsp, %rbp
     179
    176180        call main_bsp
    177181       
     
    329333
    330334extended_cpuid_msg:
    331         .asciz "Extended CPUID not supported. System halted."
     335        .asciz "Error: Extended CPUID not supported -- CPU is not 64-bit. System halted."
    332336long_mode_msg:
    333         .asciz "64 bit long mode not supported. System halted."
     337        .asciz "Error: 64-bit long mode not supported. System halted."
    334338noexecute_msg:
    335         .asciz "No-execute pages not supported. System halted."
     339        .asciz "Error: No-execute pages not supported. System halted."
    336340fx_msg:
    337         .asciz "FXSAVE/FXRESTORE instructions not supported. System halted."
     341        .asciz "Error: FXSAVE/FXRESTORE instructions not supported. System halted."
    338342sse2_msg:
    339         .asciz "SSE2 instructions not supported. System halted."
     343        .asciz "Error: SSE2 instructions not supported. System halted."
  • kernel/arch/amd64/src/cpu/cpu.c

    r309ede1 r5f70118  
    130130        CPU->arch.vendor = VendorUnknown;
    131131        if (has_cpuid()) {
    132                 cpuid(0, &info);
     132                cpuid(INTEL_CPUID_LEVEL, &info);
    133133
    134134                /*
     
    150150                }
    151151                               
    152                 cpuid(1, &info);
     152                cpuid(INTEL_CPUID_STANDARD, &info);
    153153                CPU->arch.family = (info.cpuid_eax >> 8) & 0xf;
    154154                CPU->arch.model = (info.cpuid_eax >> 4) & 0xf;
  • kernel/arch/amd64/src/interrupt.c

    r309ede1 r5f70118  
    5353#include <ddi/irq.h>
    5454#include <symtab.h>
     55#include <stacktrace.h>
    5556
    5657/*
     
    8081            istate->r10, istate->r11);
    8182        printf("%%rsp=%#llx\n", &istate->stack[0]);
     83       
     84        stack_trace_istate(istate);
    8285}
    8386
     
    9699        decode_istate(n, istate);
    97100        panic("Unserviced interrupt.");
     101}
     102
     103static void de_fault(int n, istate_t *istate)
     104{
     105        fault_if_from_uspace(istate, "Divide error.");
     106        decode_istate(n, istate);
     107        panic("Divide error.");
    98108}
    99109
     
    200210        }
    201211       
     212        exc_register(0, "de_fault", (iroutine) de_fault);
    202213        exc_register(7, "nm_fault", (iroutine) nm_fault);
    203214        exc_register(12, "ss_fault", (iroutine) ss_fault);
  • kernel/arch/amd64/src/mm/page.c

    r309ede1 r5f70118  
    203203{
    204204        if (last_frame + ALIGN_UP(size, PAGE_SIZE) > KA2PA(KERNEL_ADDRESS_SPACE_END_ARCH))
    205                 panic("Unable to map physical memory %p (%d bytes).", physaddr, size)
     205                panic("Unable to map physical memory %p (%d bytes).", physaddr,
     206                    size);
    206207       
    207208        uintptr_t virtaddr = PA2KA(last_frame);
  • kernel/arch/amd64/src/smp/ap.S

    r309ede1 r5f70118  
    9999start64:
    100100        movq (ctx), %rsp
     101        pushq $0
     102        movq %rsp, %rbp
    101103        call main_ap - AP_BOOT_OFFSET + BOOT_OFFSET   # never returns
    102104
  • kernel/arch/arm32/Makefile.inc

    r309ede1 r5f70118  
    5757        arch/$(KARCH)/src/exception.c \
    5858        arch/$(KARCH)/src/userspace.c \
     59        arch/$(KARCH)/src/debug/stacktrace.c \
     60        arch/$(KARCH)/src/debug/stacktrace_asm.S \
    5961        arch/$(KARCH)/src/mm/as.c \
    6062        arch/$(KARCH)/src/mm/frame.c \
    6163        arch/$(KARCH)/src/mm/page.c \
    6264        arch/$(KARCH)/src/mm/tlb.c \
    63         arch/$(KARCH)/src/mm/page_fault.c
     65        arch/$(KARCH)/src/mm/page_fault.c \
     66        arch/$(KARCH)/src/ras.c
    6467
    6568ifeq ($(MACHINE),testarm)
  • kernel/arch/arm32/_link.ld.in

    r309ede1 r5f70118  
    3434                *(.sdata);
    3535                *(.reginfo);
     36                . = ALIGN(8);
    3637                symbol_table = .;
    3738                *(symtab.*);
  • kernel/arch/arm32/include/atomic.h

    r309ede1 r5f70118  
    3737#define KERN_arm32_ATOMIC_H_
    3838
     39#include <arch/asm.h>
     40
    3941/** Atomic addition.
    4042 *
     
    4749static inline long atomic_add(atomic_t *val, int i)
    4850{
    49         int ret;
    50         volatile long *mem = &(val->count);
    51        
    52         asm volatile (
    53                 "1:\n"
    54                         "ldr r2, [%[mem]]\n"
    55                         "add r3, r2, %[i]\n"
    56                         "str r3, %[ret]\n"
    57                         "swp r3, r3, [%[mem]]\n"
    58                         "cmp r3, r2\n"
    59                         "bne 1b\n"
    60                 : [ret] "=m" (ret)
    61                 : [mem] "r" (mem), [i] "r" (i)
    62                 : "r3", "r2"
    63         );
     51        long ret;
     52
     53        /*
     54         * This implementation is for UP pre-ARMv6 systems where we do not have
     55         * the LDREX and STREX instructions.
     56         */
     57        ipl_t ipl = interrupts_disable();
     58        val->count += i;
     59        ret = val->count;
     60        interrupts_restore(ipl);
    6461       
    6562        return ret;
  • kernel/arch/arm32/include/exception.h

    r309ede1 r5f70118  
    8686
    8787/** Struct representing CPU state saved when an exception occurs. */
    88 typedef struct {
     88typedef struct istate {
    8989        uint32_t spsr;
    9090        uint32_t sp;
     
    133133}
    134134
     135static inline unative_t istate_get_fp(istate_t *istate)
     136{
     137        return istate->r11;
     138}
     139
    135140
    136141extern void install_exception_handlers(void);
  • kernel/arch/arm32/include/mm/as.h

    r309ede1 r5f70118  
    5454#define as_destructor_arch(as)                  (as != as)
    5555#define as_create_arch(as, flags)               (as != as)
    56 #define as_install_arch(as)
    5756#define as_deinstall_arch(as)
    5857#define as_invalidate_translation_cache(as, page, cnt)
  • kernel/arch/arm32/include/mm/page.h

    r309ede1 r5f70118  
    7575/* Get PTE address accessors for each level. */
    7676#define GET_PTL1_ADDRESS_ARCH(ptl0, i) \
    77         ((pte_t *) ((((pte_level0_t *)(ptl0))[(i)]).coarse_table_addr << 10))
     77        ((pte_t *) ((((pte_t *)(ptl0))[(i)].l0).coarse_table_addr << 10))
    7878#define GET_PTL2_ADDRESS_ARCH(ptl1, i) \
    7979        (ptl1)
     
    8181        (ptl2)
    8282#define GET_FRAME_ADDRESS_ARCH(ptl3, i) \
    83         ((uintptr_t) ((((pte_level1_t *)(ptl3))[(i)]).frame_base_addr << 12))
     83        ((uintptr_t) ((((pte_t *)(ptl3))[(i)].l1).frame_base_addr << 12))
    8484
    8585/* Set PTE address accessors for each level. */
    8686#define SET_PTL0_ADDRESS_ARCH(ptl0) \
    87         (set_ptl0_addr((pte_level0_t *) (ptl0)))
     87        (set_ptl0_addr((pte_t *) (ptl0)))
    8888#define SET_PTL1_ADDRESS_ARCH(ptl0, i, a) \
    89         (((pte_level0_t *) (ptl0))[(i)].coarse_table_addr = (a) >> 10)
     89        (((pte_t *) (ptl0))[(i)].l0.coarse_table_addr = (a) >> 10)
    9090#define SET_PTL2_ADDRESS_ARCH(ptl1, i, a)
    9191#define SET_PTL3_ADDRESS_ARCH(ptl2, i, a)
    9292#define SET_FRAME_ADDRESS_ARCH(ptl3, i, a) \
    93         (((pte_level1_t *) (ptl3))[(i)].frame_base_addr = (a) >> 12)
     93        (((pte_t *) (ptl3))[(i)].l1.frame_base_addr = (a) >> 12)
    9494
    9595/* Get PTE flags accessors for each level. */
    9696#define GET_PTL1_FLAGS_ARCH(ptl0, i) \
    97         get_pt_level0_flags((pte_level0_t *) (ptl0), (size_t) (i))
     97        get_pt_level0_flags((pte_t *) (ptl0), (size_t) (i))
    9898#define GET_PTL2_FLAGS_ARCH(ptl1, i) \
    9999        PAGE_PRESENT
     
    101101        PAGE_PRESENT
    102102#define GET_FRAME_FLAGS_ARCH(ptl3, i) \
    103         get_pt_level1_flags((pte_level1_t *) (ptl3), (size_t) (i))
     103        get_pt_level1_flags((pte_t *) (ptl3), (size_t) (i))
    104104
    105105/* Set PTE flags accessors for each level. */
    106106#define SET_PTL1_FLAGS_ARCH(ptl0, i, x) \
    107         set_pt_level0_flags((pte_level0_t *) (ptl0), (size_t) (i), (x))
     107        set_pt_level0_flags((pte_t *) (ptl0), (size_t) (i), (x))
    108108#define SET_PTL2_FLAGS_ARCH(ptl1, i, x)
    109109#define SET_PTL3_FLAGS_ARCH(ptl2, i, x)
    110110#define SET_FRAME_FLAGS_ARCH(ptl3, i, x) \
    111         set_pt_level1_flags((pte_level1_t *) (ptl3), (size_t) (i), (x))
     111        set_pt_level1_flags((pte_t *) (ptl3), (size_t) (i), (x))
    112112
    113113/* Macros for querying the last-level PTE entries. */
     
    115115        (*((uint32_t *) (pte)) != 0)
    116116#define PTE_PRESENT_ARCH(pte) \
    117         (((pte_level0_t *) (pte))->descriptor_type != 0)
     117        (((pte_t *) (pte))->l0.descriptor_type != 0)
    118118#define PTE_GET_FRAME_ARCH(pte) \
    119         (((pte_level1_t *) (pte))->frame_base_addr << FRAME_WIDTH)
     119        (((pte_t *) (pte))->l1.frame_base_addr << FRAME_WIDTH)
    120120#define PTE_WRITABLE_ARCH(pte) \
    121         (((pte_level1_t *) (pte))->access_permission_0 == \
    122             PTE_AP_USER_RW_KERNEL_RW)
     121        (((pte_t *) (pte))->l1.access_permission_0 == PTE_AP_USER_RW_KERNEL_RW)
    123122#define PTE_EXECUTABLE_ARCH(pte) \
    124123        1
     
    159158} ATTRIBUTE_PACKED pte_level1_t;
    160159
     160typedef union {
     161        pte_level0_t l0;
     162        pte_level1_t l1;
     163} pte_t;
    161164
    162165/* Level 1 page tables access permissions */
     
    191194 * @param pt    Pointer to the page table to set.
    192195 */   
    193 static inline void set_ptl0_addr(pte_level0_t *pt)
     196static inline void set_ptl0_addr(pte_t *pt)
    194197{
    195198        asm volatile (
     
    205208 *  @param i      Index of the entry to return.
    206209 */
    207 static inline int get_pt_level0_flags(pte_level0_t *pt, size_t i)
    208 {
    209         pte_level0_t *p = &pt[i];
     210static inline int get_pt_level0_flags(pte_t *pt, size_t i)
     211{
     212        pte_level0_t *p = &pt[i].l0;
    210213        int np = (p->descriptor_type == PTE_DESCRIPTOR_NOT_PRESENT);
    211214
     
    220223 *  @param i      Index of the entry to return.
    221224 */
    222 static inline int get_pt_level1_flags(pte_level1_t *pt, size_t i)
    223 {
    224         pte_level1_t *p = &pt[i];
     225static inline int get_pt_level1_flags(pte_t *pt, size_t i)
     226{
     227        pte_level1_t *p = &pt[i].l1;
    225228
    226229        int dt = p->descriptor_type;
     
    245248 *  @param flags  new flags
    246249 */
    247 static inline void set_pt_level0_flags(pte_level0_t *pt, size_t i, int flags)
    248 {
    249         pte_level0_t *p = &pt[i];
     250static inline void set_pt_level0_flags(pte_t *pt, size_t i, int flags)
     251{
     252        pte_level0_t *p = &pt[i].l0;
    250253
    251254        if (flags & PAGE_NOT_PRESENT) {
     
    273276 *  @param flags  New flags.
    274277 */ 
    275 static inline void set_pt_level1_flags(pte_level1_t *pt, size_t i, int flags)
    276 {
    277         pte_level1_t *p = &pt[i];
     278static inline void set_pt_level1_flags(pte_t *pt, size_t i, int flags)
     279{
     280        pte_level1_t *p = &pt[i].l1;
    278281       
    279282        if (flags & PAGE_NOT_PRESENT) {
  • kernel/arch/arm32/include/types.h

    r309ede1 r5f70118  
    8787#define PRIxn "x"       /**< Format for hexadecimal (u)native_t. */
    8888
    89 /** Page table entry.
    90  *
    91  *  We have different structs for level 0 and level 1 page table entries.
    92  *  See page.h for definition of pte_level*_t.
    93  */
    94 typedef struct {
    95         unsigned dummy : 32;
    96 } pte_t;
    97 
    9889#endif
    9990
  • kernel/arch/arm32/src/arm32.c

    r309ede1 r5f70118  
    4848#include <macros.h>
    4949#include <string.h>
     50#include <arch/ras.h>
    5051
    5152#ifdef MACHINE_testarm
     
    8889        exception_init();
    8990        interrupt_init();
     91
     92        /* Initialize Restartable Atomic Sequences support. */
     93        ras_init();
    9094       
    9195        machine_output_init();
     
    136140        uint8_t *stck;
    137141       
    138         tlb_invalidate_all();
    139142        stck = &THREAD->kstack[THREAD_STACK_SIZE - SP_DELTA];
    140143        supervisor_sp = (uintptr_t) stck;
  • kernel/arch/arm32/src/debug/stacktrace.c

    r309ede1 r5f70118  
    11/*
    2  * Copyright (c) 2005 Jakub Jermar
     2 * Copyright (c) 2010 Jakub Jermar
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup mips32 
     29/** @addtogroup arm32
    3030 * @{
    3131 */
     
    3333 */
    3434
    35 #ifndef KERN_mips32_ARG_H_
    36 #define KERN_mips32_ARG_H_
     35#include <stacktrace.h>
     36#include <syscall/copy.h>
     37#include <arch/types.h>
     38#include <typedefs.h>
    3739
    38 #include <arch/types.h>
     40bool kernel_frame_pointer_validate(uintptr_t fp)
     41{
     42        return false;
     43}
    3944
    40 /**
    41  * va_arg macro for MIPS32 - problem is that 64 bit values must be aligned on an 8-byte boundary (32bit values not)
    42  * To satisfy this, paddings must be sometimes inserted.
    43  */
     45bool kernel_frame_pointer_prev(uintptr_t fp, uintptr_t *prev)
     46{
     47        return false;
     48}
    4449
    45 typedef uintptr_t va_list;
     50bool kernel_return_address_get(uintptr_t fp, uintptr_t *ra)
     51{
     52        return false;
     53}
    4654
    47 #define va_start(ap, lst) \
    48         ((ap) = (va_list)&(lst) + sizeof(lst))
     55bool uspace_frame_pointer_validate(uintptr_t fp)
     56{
     57        return false;
     58}
    4959
    50 #define va_arg(ap, type)        \
    51         (((type *)((ap) = (va_list)( (sizeof(type) <= 4) ? ((uintptr_t)((ap) + 2*4 - 1) & (~3)) : ((uintptr_t)((ap) + 2*8 -1) & (~7)) )))[-1])
     60bool uspace_frame_pointer_prev(uintptr_t fp, uintptr_t *prev)
     61{
     62        return false;
     63}
    5264
    53 #define va_copy(dst,src) ((dst)=(src))
    54 
    55 #define va_end(ap)
    56 
    57 #endif
     65bool uspace_return_address_get(uintptr_t fp, uintptr_t *ra)
     66{
     67        return false;
     68}
    5869
    5970/** @}
  • kernel/arch/arm32/src/exc_handler.S

    r309ede1 r5f70118  
    148148        mov r0, #0
    149149        mov r1, r13
    150         bl exc_dispatch
     150        bl ras_check
    151151        LOAD_REGS_FROM_STACK
    152152
     
    156156        mov r0, #5
    157157        mov r1, r13
    158         bl exc_dispatch
     158        bl ras_check
    159159        LOAD_REGS_FROM_STACK
    160160
     
    164164        mov r0, #6
    165165        mov r1, r13
    166         bl exc_dispatch
     166        bl ras_check
    167167        LOAD_REGS_FROM_STACK
    168168
     
    171171        mov r0, #1
    172172        mov r1, r13
    173         bl exc_dispatch
     173        bl ras_check
    174174        LOAD_REGS_FROM_STACK
    175175
     
    179179        mov r0, #3
    180180        mov r1, r13
    181         bl exc_dispatch
     181        bl ras_check
    182182        LOAD_REGS_FROM_STACK
    183183
     
    187187        mov r0, #4
    188188        mov r1, r13
    189         bl exc_dispatch
     189        bl ras_check
    190190        LOAD_REGS_FROM_STACK
    191191
     
    195195        mov r0, #2
    196196        mov r1, r13
    197         bl exc_dispatch
     197        bl ras_check
    198198        LOAD_REGS_FROM_STACK
    199199
  • kernel/arch/arm32/src/mm/as.c

    r309ede1 r5f70118  
    3636#include <arch/mm/as.h>
    3737#include <genarch/mm/as_pt.h>
     38#include <genarch/mm/page_pt.h>
    3839#include <genarch/mm/asid_fifo.h>
    3940#include <mm/as.h>
     41#include <mm/tlb.h>
    4042#include <arch.h>
    4143
     
    4951}
    5052
     53void as_install_arch(as_t *as)
     54{
     55        tlb_invalidate_all();
     56}
     57
    5158/** @}
    5259 */
  • kernel/arch/arm32/src/mm/page.c

    r309ede1 r5f70118  
    8888            KA2PA(KERNEL_ADDRESS_SPACE_END_ARCH)) {
    8989                panic("Unable to map physical memory %p (%d bytes).",
    90                     physaddr, size)
     90                    physaddr, size);
    9191        }
    9292       
  • kernel/arch/arm32/src/userspace.c

    r309ede1 r5f70118  
    3535
    3636#include <userspace.h>
     37#include <arch/ras.h>
    3738
    3839/** Struct for holding all general purpose registers.
     
    7475        ustate.r1 = 0;
    7576
     77        /* pass the RAS page address in %r2 */
     78        ustate.r2 = (uintptr_t) ras_page;
     79
    7680        /* clear other registers */
    77         ustate.r2 = ustate.r3  = ustate.r4  = ustate.r5 =
    78             ustate.r6  = ustate.r7  = ustate.r8  = ustate.r9 = ustate.r10 =
    79             ustate.r11 = ustate.r12 = ustate.lr = 0;
     81        ustate.r3  = ustate.r4  = ustate.r5 = ustate.r6 = ustate.r7 =
     82            ustate.r8 = ustate.r9 = ustate.r10 = ustate.r11 = ustate.r12 =
     83            ustate.lr = 0;
    8084
    8185        /* set user stack */
  • 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"
  • kernel/arch/ia64/Makefile.inc

    r309ede1 r5f70118  
    5353        arch/$(KARCH)/src/context.S \
    5454        arch/$(KARCH)/src/cpu/cpu.c \
     55        arch/$(KARCH)/src/debug/stacktrace.c \
     56        arch/$(KARCH)/src/debug/stacktrace_asm.S \
    5557        arch/$(KARCH)/src/ivt.S \
    5658        arch/$(KARCH)/src/interrupt.c \
  • kernel/arch/ia64/_link.ld.in

    r309ede1 r5f70118  
    77 */
    88
     9#define LOAD_ADDRESS_V  0xe000000004404000
     10#define LOAD_ADDRESS_P  0x0000000004404000
     11
    912ENTRY(kernel_image_start)
    1013
    1114SECTIONS {
    12         .image 0xe000000004404000: AT (0x0000000004404000) {
     15        .image LOAD_ADDRESS_V: AT (LOAD_ADDRESS_P) {
    1316                ktext_start = .;
    1417                *(K_TEXT_START);
     
    2124                *(.opd)
    2225                *(.data .data.*)
     26                hardcoded_load_address = .;
     27                QUAD(LOAD_ADDRESS_V);
     28                hardcoded_ktext_size = .;
     29                QUAD(ktext_end - ktext_start);
     30                hardcoded_kdata_size = .;
     31                QUAD(kdata_end - kdata_start);
    2332                *(.got .got.*)
    2433                *(.sdata)
     
    2837                *(COMMON);
    2938
     39                . = ALIGN(8);
    3040                symbol_table = .;
    3141                *(symtab.*);            /* Symbol table, must be LAST symbol!*/
     
    3848        }
    3949
    40         _hardcoded_ktext_size = ktext_end - ktext_start;
    41         _hardcoded_kdata_size = kdata_end - kdata_start;
    42         _hardcoded_load_address = 0xe000000004404000;
    43 
    4450}
  • kernel/arch/ia64/include/asm.h

    r309ede1 r5f70118  
    422422        asm volatile (
    423423                "rsm %[mask]\n"
     424                ";;\n"
     425                "srlz.d\n"
    424426                :: [mask] "i" (PSR_PK_MASK)
    425427        );
  • kernel/arch/ia64/include/interrupt.h

    r309ede1 r5f70118  
    7272#define EOI  0  /**< The actual value doesn't matter. */
    7373
    74 typedef struct {
     74typedef struct istate {
    7575        uint128_t f2;
    7676        uint128_t f3;
     
    143143}
    144144
     145static inline unative_t istate_get_fp(istate_t *istate)
     146{
     147        return 0;       /* FIXME */
     148}
     149
    145150static inline int istate_from_uspace(istate_t *istate)
    146151{
  • kernel/arch/ia64/src/cpu/cpu.c

    r309ede1 r5f70118  
    3737#include <arch/register.h>
    3838#include <print.h>
     39#include <memstr.h>
    3940
    4041void cpu_arch_init(void)
  • kernel/arch/ia64/src/debug/stacktrace.c

    r309ede1 r5f70118  
    11/*
    2  * Copyright (c) 2005 Jakub Jermar
     2 * Copyright (c) 2010 Jakub Jermar
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup generic
     29/** @addtogroup ia64
    3030 * @{
    3131 */
     
    3333 */
    3434
    35 /*
    36  * Variable argument list manipulation macros
    37  * for architectures using stack to pass arguments.
    38  */
    39  
    40 #ifndef KERN_STACKARG_H_
    41 #define KERN_STACKARG_H_
     35#include <stacktrace.h>
     36#include <syscall/copy.h>
     37#include <arch/types.h>
     38#include <typedefs.h>
    4239
    43 #include <arch/types.h>
     40bool kernel_frame_pointer_validate(uintptr_t fp)
     41{
     42        return false;
     43}
    4444
    45 typedef struct va_list {
    46         int pos;
    47         uint8_t *last;
    48 } va_list;
     45bool kernel_frame_pointer_prev(uintptr_t fp, uintptr_t *prev)
     46{
     47        return false;
     48}
    4949
    50 #define va_start(ap, lst)               \
    51         (ap).pos = sizeof(lst);                         \
    52         (ap).last = (uint8_t *) &(lst)
     50bool kernel_return_address_get(uintptr_t fp, uintptr_t *ra)
     51{
     52        return false;
     53}
    5354
    54 #define va_arg(ap, type)                \
    55         (*((type *)((ap).last + ((ap).pos += sizeof(type)) - sizeof(type))))
     55bool uspace_frame_pointer_validate(uintptr_t fp)
     56{
     57        return false;
     58}
    5659
    57 #define va_copy(dst, src) dst = src
    58 #define va_end(ap)
     60bool uspace_frame_pointer_prev(uintptr_t fp, uintptr_t *prev)
     61{
     62        return false;
     63}
    5964
    60 
    61 #endif
     65bool uspace_return_address_get(uintptr_t fp, uintptr_t *ra)
     66{
     67        return false;
     68}
    6269
    6370/** @}
  • kernel/arch/ia64/src/ivt.S

    r309ede1 r5f70118  
    391391
    392392    /* 10. call handler */
    393         movl r1 = _hardcoded_load_address
     393        movl r1 = kernel_image_start
    394394   
    395395        mov b1 = loc2
  • kernel/arch/ia64/src/mm/as.c

    r309ede1 r5f70118  
    7373                rr.map.ps = PAGE_WIDTH;
    7474                rr_write(i, rr.word);
     75                srlz_d();
     76                srlz_i();
    7577        }
    76         srlz_d();
    77         srlz_i();
    7878}
    7979
  • kernel/arch/ia64/src/start.S

    r309ede1 r5f70118  
    186186        movl r20 = (VRN_KERNEL << VRN_SHIFT) ;;
    187187        or r20 = r20, r1 ;;
    188         movl r1 = _hardcoded_load_address
     188        movl r1 = kernel_image_start
    189189       
    190190        /*
    191          * Initialize hardcoded_* variables. Do only BSP
     191         * Initialize bootinfo on BSP.
    192192         */
    193 (p3)    movl r14 = _hardcoded_ktext_size
    194 (p3)    movl r15 = _hardcoded_kdata_size
    195 (p3)    movl r16 = _hardcoded_load_address ;;
    196 (p3)    addl r17 = @gprel(hardcoded_ktext_size), gp
    197 (p3)    addl r18 = @gprel(hardcoded_kdata_size), gp
    198 (p3)    addl r19 = @gprel(hardcoded_load_address), gp
    199 (p3)    addl r21 = @gprel(bootinfo), gp
    200                 ;;
    201 (p3)    st8 [r17] = r14
    202 (p3)    st8 [r18] = r15
    203 (p3)    st8 [r19] = r16
     193(p3)    addl r21 = @gprel(bootinfo), gp ;;
    204194(p3)    st8 [r21] = r20
    205195       
  • kernel/arch/mips32/Makefile.inc

    r309ede1 r5f70118  
    7070        arch/$(KARCH)/src/debugger.c \
    7171        arch/$(KARCH)/src/cpu/cpu.c \
     72        arch/$(KARCH)/src/debug/stacktrace.c \
     73        arch/$(KARCH)/src/debug/stacktrace_asm.S \
    7274        arch/$(KARCH)/src/mm/frame.c \
    7375        arch/$(KARCH)/src/mm/page.c \
  • kernel/arch/mips32/_link.ld.in

    r309ede1 r5f70118  
    3838                *(.bss);                        /* uninitialized static variables */
    3939                *(COMMON);                      /* global variables */
     40                . = ALIGN(8);
    4041                symbol_table = .;
    4142                *(symtab.*);
  • kernel/arch/mips32/include/exception.h

    r309ede1 r5f70118  
    5858#define EXC_VCED        31
    5959
    60 typedef struct {
     60typedef struct istate {
    6161        uint32_t at;
    6262        uint32_t v0;
     
    102102        return istate->epc;
    103103}
     104static inline unative_t istate_get_fp(istate_t *istate)
     105{
     106        return 0;       /* FIXME */
     107}
    104108
    105109extern void exception(istate_t *istate);
  • kernel/arch/mips32/include/mm/page.h

    r309ede1 r5f70118  
    141141#include <arch/exception.h>
    142142
    143 static inline int get_pt_flags(pte_t *pt, size_t i)
     143/** Page Table Entry. */
     144typedef struct {
     145        unsigned g : 1;                 /**< Global bit. */
     146        unsigned p : 1;                 /**< Present bit. */
     147        unsigned d : 1;                 /**< Dirty bit. */
     148        unsigned cacheable : 1;         /**< Cacheable bit. */
     149        unsigned : 1;                   /**< Unused. */
     150        unsigned soft_valid : 1;        /**< Valid content even if not present. */
     151        unsigned pfn : 24;              /**< Physical frame number. */
     152        unsigned w : 1;                 /**< Page writable bit. */
     153        unsigned a : 1;                 /**< Accessed bit. */
     154} pte_t;
     155
     156
     157static inline unsigned int get_pt_flags(pte_t *pt, size_t i)
    144158{
    145159        pte_t *p = &pt[i];
  • kernel/arch/mips32/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 g : 1;                 /**< Global bit. */
    85         unsigned p : 1;                 /**< Present bit. */
    86         unsigned d : 1;                 /**< Dirty bit. */
    87         unsigned cacheable : 1;         /**< Cacheable bit. */
    88         unsigned : 1;                   /**< Unused. */
    89         unsigned soft_valid : 1;        /**< Valid content even if not present. */
    90         unsigned pfn : 24;              /**< Physical frame number. */
    91         unsigned w : 1;                 /**< Page writable bit. */
    92         unsigned a : 1;                 /**< Accessed bit. */
    93 } pte_t;
    94 
    9582#endif
    9683
  • kernel/arch/mips32/src/debug/stacktrace.c

    r309ede1 r5f70118  
    11/*
    2  * Copyright (c) 2005 Jakub Jermar
     2 * Copyright (c) 2010 Jakub Jermar
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup libcia32
     29/** @addtogroup mips32
    3030 * @{
    3131 */
     
    3333 */
    3434
    35 /*
    36  * Variable argument list manipulation macros
    37  * for architectures using stack to pass arguments.
    38  */
    39  
    40 #ifndef LIBC_ia32_STACKARG_H_
    41 #define LIBC_ia32_STACKARG_H_
     35#include <stacktrace.h>
     36#include <syscall/copy.h>
     37#include <arch/types.h>
     38#include <typedefs.h>
    4239
    43 #include <sys/types.h>
     40bool kernel_frame_pointer_validate(uintptr_t fp)
     41{
     42        return false;
     43}
    4444
    45 /* dont allow to define it second time in stdarg.h */
    46 #define __VARARGS_DEFINED
     45bool kernel_frame_pointer_prev(uintptr_t fp, uintptr_t *prev)
     46{
     47        return false;
     48}
    4749
    48 typedef struct va_list {
    49         int pos;
    50         uint8_t *last;
    51 } va_list;
     50bool kernel_return_address_get(uintptr_t fp, uintptr_t *ra)
     51{
     52        return false;
     53}
    5254
    53 #define va_start(ap, lst) \
    54         (ap).pos = sizeof(lst);                         \
    55         (ap).last = (uint8_t *) &(lst)
     55bool uspace_frame_pointer_validate(uintptr_t fp)
     56{
     57        return false;
     58}
    5659
    57 #define va_arg(ap, type)                \
    58         (*((type *)((ap).last + ((ap).pos  += sizeof(type) ) - sizeof(type))))
     60bool uspace_frame_pointer_prev(uintptr_t fp, uintptr_t *prev)
     61{
     62        return false;
     63}
    5964
    60 #define va_end(ap)
    61 
    62 
    63 #endif
     65bool uspace_return_address_get(uintptr_t fp, uintptr_t *ra)
     66{
     67        return false;
     68}
    6469
    6570/** @}
  • kernel/arch/ppc32/Makefile.inc

    r309ede1 r5f70118  
    4646        arch/$(KARCH)/src/context.S \
    4747        arch/$(KARCH)/src/debug/panic.s \
     48        arch/$(KARCH)/src/debug/stacktrace.c \
     49        arch/$(KARCH)/src/debug/stacktrace_asm.S \
    4850        arch/$(KARCH)/src/fpu_context.S \
    4951        arch/$(KARCH)/src/boot/boot.S \
  • kernel/arch/ppc32/_link.ld.in

    r309ede1 r5f70118  
    5151                *(COMMON);      /* global variables */
    5252               
     53                . = ALIGN(8);
    5354                symbol_table = .;
    5455                *(symtab.*);    /* Symbol table, must be LAST symbol!*/
  • kernel/arch/ppc32/include/exception.h

    r309ede1 r5f70118  
    3939#include <arch/regutils.h>
    4040
    41 typedef struct {
     41typedef struct istate {
    4242        uint32_t r0;
    4343        uint32_t r2;
     
    9898}
    9999
     100static inline unative_t istate_get_fp(istate_t *istate)
     101{
     102        return istate->sp;
     103}
     104
    100105#endif
    101106
  • kernel/arch/ppc32/include/mm/page.h

    r309ede1 r5f70118  
    131131#include <arch/interrupt.h>
    132132
    133 static inline int get_pt_flags(pte_t *pt, size_t i)
     133/** Page Table Entry. */
     134typedef struct {
     135        unsigned present : 1;             /**< Present bit. */
     136        unsigned page_write_through : 1;  /**< Write thought caching. */
     137        unsigned page_cache_disable : 1;  /**< No caching. */
     138        unsigned accessed : 1;            /**< Accessed bit. */
     139        unsigned global : 1;              /**< Global bit. */
     140        unsigned valid : 1;               /**< Valid content even if not present. */
     141        unsigned pfn : 20;                /**< Physical frame number. */
     142} pte_t;
     143
     144static inline unsigned int get_pt_flags(pte_t *pt, size_t i)
    134145{
    135146        pte_t *p = &pt[i];
  • kernel/arch/ppc32/include/types.h

    r309ede1 r5f70118  
    8282#define PRIxn "x"
    8383
    84 /** Page Table Entry. */
    85 typedef struct {
    86         unsigned present : 1;             /**< Present bit. */
    87         unsigned page_write_through : 1;  /**< Write thought caching. */
    88         unsigned page_cache_disable : 1;  /**< No caching. */
    89         unsigned accessed : 1;            /**< Accessed bit. */
    90         unsigned global : 1;              /**< Global bit. */
    91         unsigned valid : 1;               /**< Valid content even if not present. */
    92         unsigned pfn : 20;                /**< Physical frame number. */
    93 } pte_t;
    94 
    9584#endif
    9685
  • kernel/arch/ppc32/src/mm/as.c

    r309ede1 r5f70118  
    3535#include <arch/mm/as.h>
    3636#include <genarch/mm/as_pt.h>
     37#include <genarch/mm/page_pt.h>
    3738#include <genarch/mm/asid_fifo.h>
    3839#include <arch.h>
  • kernel/arch/ppc32/src/mm/page.c

    r309ede1 r5f70118  
    5151            KA2PA(KERNEL_ADDRESS_SPACE_END_ARCH))
    5252                panic("Unable to map physical memory %p (%" PRIs " bytes).",
    53                     physaddr, size)
     53                    physaddr, size);
    5454       
    5555        uintptr_t virtaddr = PA2KA(last_frame);
  • kernel/arch/ppc32/src/mm/tlb.c

    r309ede1 r5f70118  
    3838#include <interrupt.h>
    3939#include <mm/as.h>
     40#include <mm/page.h>
    4041#include <arch.h>
    4142#include <print.h>
  • kernel/arch/ppc32/src/ppc32.c

    r309ede1 r5f70118  
    4444#include <genarch/ofw/pci.h>
    4545#include <userspace.h>
     46#include <mm/page.h>
    4647#include <proc/uarg.h>
    4748#include <console/console.h>
  • kernel/arch/sparc64/Makefile.inc

    r309ede1 r5f70118  
    5454ARCH_SOURCES = \
    5555        arch/$(KARCH)/src/cpu/cpu.c \
     56        arch/$(KARCH)/src/debug/stacktrace.c \
     57        arch/$(KARCH)/src/debug/stacktrace_asm.S \
    5658        arch/$(KARCH)/src/asm.S \
    5759        arch/$(KARCH)/src/panic.S \
  • kernel/arch/sparc64/_link.ld.in

    r309ede1 r5f70118  
    3636                *(COMMON);                  /* global variables */
    3737               
     38                . = ALIGN(8);
    3839                symbol_table = .;
    3940                *(symtab.*);                /* Symbol table, must be LAST symbol!*/
  • kernel/arch/sparc64/include/interrupt.h

    r309ede1 r5f70118  
    5050};             
    5151
    52 typedef struct {
     52typedef struct istate {
    5353        uint64_t        tnpc;
    5454        uint64_t        tpc;
     
    7171}
    7272
     73static inline unative_t istate_get_fp(istate_t *istate)
     74{
     75        return 0;       /* TODO */
     76}
     77
    7378#endif
    7479
  • kernel/arch/sparc64/src/context.S

    r309ede1 r5f70118  
    2828
    2929#include <arch/context_offset.h>
    30 
    31 /**
    32  * Both context_save_arch() and context_restore_arch() are
    33  * leaf-optimized procedures. This kind of optimization
    34  * is very important and prevents any implicit window
    35  * spill/fill/clean traps in these very core kernel
    36  * functions.
    37  */
    38        
    39 #include <arch/context_offset.h>
     30#include <arch/arch.h>
     31#include <arch/regdef.h>
    4032
    4133.text   
     
    4436.global context_restore_arch
    4537
     38/*
     39 * context_save_arch() is required not to create its own stack frame. See the
     40 * generic context.h for explanation.
     41 */
    4642context_save_arch:
     43        #
     44        # Force all our active register windows to memory so that we can find
     45        # them there even if e.g. the thread is migrated to another processor.
     46        #
     47        flushw
     48
    4749        CONTEXT_SAVE_ARCH_CORE %o0
    4850        retl
     
    5153context_restore_arch:
    5254        #
    53         # Flush all active windows.
    54         # This is essential, because CONTEXT_LOAD overwrites
    55         # %sp of CWP - 1 with the value written to %fp of CWP.
    56         # Flushing all active windows mitigates this problem
    57         # as CWP - 1 becomes the overlap window.
     55        # Forget all previous windows, they are not going to be needed again.
     56        # Enforce a window fill on the next RESTORE instruction by setting
     57        # CANRESTORE to zero and other window configuration registers
     58        # accordingly. Note that the same can be achieved by executing the
     59        # FLUSHW instruction, but since we don't need to remember the previous
     60        # windows, we do the former and save thus some unnecessary window
     61        # spills.
    5862        #
    59         flushw
    60        
     63        rdpr %pstate, %l0
     64        andn %l0, PSTATE_IE_BIT, %l1
     65        wrpr %l1, %pstate
     66        wrpr %g0, 0, %canrestore
     67        wrpr %g0, 0, %otherwin
     68        wrpr %g0, NWINDOWS - 2, %cansave
     69        wrpr %l0, %pstate
     70
    6171        CONTEXT_RESTORE_ARCH_CORE %o0
    6272        retl
  • kernel/arch/sparc64/src/mm/tlb.c

    r309ede1 r5f70118  
    3737#include <mm/as.h>
    3838#include <mm/asid.h>
     39#include <genarch/mm/page_ht.h>
    3940#include <arch/mm/frame.h>
    4041#include <arch/mm/page.h>
  • kernel/arch/sparc64/src/trap/trap_table.S

    r309ede1 r5f70118  
    652652         * spilled to kernel memory (i.e. register window buffer). Moreover,
    653653         * if the scheduler was called in the meantime, all valid windows
    654          * belonging to other threads were spilled by context_restore().
     654         * belonging to other threads were spilled by context_save().
    655655         * If OTHERWIN is non-zero, then some userspace windows are still
    656656         * valid. Others might have been spilled. However, the CWP pointer
Note: See TracChangeset for help on using the changeset viewer.