Changeset 60898b6 in mainline for kernel


Ignore:
Timestamp:
2010-11-05T16:17:48Z (15 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
08042bd
Parents:
a63ff7d (diff), a66e2993 (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
Files:
8 added
16 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/abs32le/include/interrupt.h

    ra63ff7d r60898b6  
    3737
    3838#include <typedefs.h>
    39 #include <verify.h>
    40 #include <trace.h>
     39#include <arch/istate.h>
    4140
    4241#define IVT_ITEMS  0
     
    4544#define VECTOR_TLB_SHOOTDOWN_IPI  0
    4645
    47 /*
    48  * On real hardware this stores the registers which
    49  * need to be preserved during interupts.
    50  */
    51 typedef struct istate {
    52         uintptr_t ip;
    53         uintptr_t fp;
    54         uint32_t stack[];
    55 } istate_t;
    56 
    57 NO_TRACE static inline int istate_from_uspace(istate_t *istate)
    58     REQUIRES_EXTENT_MUTABLE(istate)
    59 {
    60         /* On real hardware this checks whether the interrupted
    61            context originated from user space. */
    62        
    63         return !(istate->ip & 0x80000000);
    64 }
    65 
    66 NO_TRACE static inline void istate_set_retaddr(istate_t *istate,
    67     uintptr_t retaddr)
    68     WRITES(&istate->ip)
    69 {
    70         /* On real hardware this sets the instruction pointer. */
    71        
    72         istate->ip = retaddr;
    73 }
    74 
    75 NO_TRACE static inline unative_t istate_get_pc(istate_t *istate)
    76     REQUIRES_EXTENT_MUTABLE(istate)
    77 {
    78         /* On real hardware this returns the instruction pointer. */
    79        
    80         return istate->ip;
    81 }
    82 
    83 NO_TRACE static inline unative_t istate_get_fp(istate_t *istate)
    84     REQUIRES_EXTENT_MUTABLE(istate)
    85 {
    86         /* On real hardware this returns the frame pointer. */
    87        
    88         return istate->fp;
    89 }
    90 
    9146#endif
    9247
  • kernel/arch/amd64/include/interrupt.h

    ra63ff7d r60898b6  
    3737
    3838#include <typedefs.h>
     39#include <arch/istate.h>
    3940#include <arch/pm.h>
    40 #include <trace.h>
    4141
    4242#define IVT_ITEMS  IDT_ITEMS
     
    7171#define VECTOR_DEBUG_IPI          (IVT_FREEBASE + 2)
    7272
    73 /** This is passed to interrupt handlers */
    74 typedef struct istate {
    75         uint64_t rax;
    76         uint64_t rbx;
    77         uint64_t rcx;
    78         uint64_t rdx;
    79         uint64_t rsi;
    80         uint64_t rdi;
    81         uint64_t rbp;
    82         uint64_t r8;
    83         uint64_t r9;
    84         uint64_t r10;
    85         uint64_t r11;
    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 */
    94         uint64_t rip;
    95         uint64_t cs;
    96         uint64_t rflags;
    97         uint64_t rsp;           /* only if istate_t is from uspace */
    98         uint64_t ss;            /* only if istate_t is from uspace */
    99 } istate_t;
    100 
    101 /** Return true if exception happened while in userspace */
    102 NO_TRACE static inline int istate_from_uspace(istate_t *istate)
    103 {
    104         return !(istate->rip & 0x8000000000000000);
    105 }
    106 
    107 NO_TRACE static inline void istate_set_retaddr(istate_t *istate,
    108     uintptr_t retaddr)
    109 {
    110         istate->rip = retaddr;
    111 }
    112 
    113 NO_TRACE static inline unative_t istate_get_pc(istate_t *istate)
    114 {
    115         return istate->rip;
    116 }
    117 
    118 NO_TRACE static inline unative_t istate_get_fp(istate_t *istate)
    119 {
    120         return istate->rbp;
    121 }
    122 
    12373extern void (* disable_irqs_function)(uint16_t);
    12474extern void (* enable_irqs_function)(uint16_t);
  • kernel/arch/amd64/src/asm.S

    ra63ff7d r60898b6  
    9595memcpy_from_uspace_failover_address:
    9696memcpy_to_uspace_failover_address:
    97         xorq %rax, %rax         /* return 0, failure */
     97        xorl %eax, %eax         /* return 0, failure */
    9898        ret
    9999
     
    143143
    144144set_efer_flag:
    145         movq $0xc0000080, %rcx
     145        movl $0xc0000080, %ecx
    146146        rdmsr
    147147        btsl %edi, %eax
     
    150150
    151151read_efer_flag:
    152         movq $0xc0000080, %rcx
     152        movl $0xc0000080, %ecx
    153153        rdmsr
    154154        ret
     
    243243         * Stop stack traces here if we came from userspace.
    244244         */
    245         xorq %rdx, %rdx
     245        xorl %edx, %edx
    246246        cmpq $(GDT_SELECTOR(KTEXT_DES)), ISTATE_OFFSET_CS(%rsp)
    247247        cmovnzq %rdx, %rbp
     
    386386        movq ISTATE_OFFSET_RSP(%rsp), %rsp
    387387
     388        /*
     389         * Clear the rest of the scratch registers to prevent information leak.
     390         * The 32-bit XOR on the low GPRs actually clears the entire 64-bit
     391         * register and the instruction is shorter.
     392         */
     393        xorl %edx, %edx
     394        xorl %esi, %esi
     395        xorl %edi, %edi
     396        xorq %r8, %r8
     397        xorq %r9, %r9
     398        xorq %r10, %r10
     399
    388400        sysretq
    389401
     
    413425        movq %rdi, %rsi
    414426        movq $(PA2KA(0xb8000)), %rdi  /* base of EGA text mode memory */
    415         xorq %rax, %rax
     427        xorl %eax, %eax
    416428       
    417429        /* Read bits 8 - 15 of the cursor address */
     
    493505                movq $(PA2KA(0xb80a0)), %rsi
    494506                movq $(PA2KA(0xb8000)), %rdi
    495                 movq $480, %rcx
     507                movl $480, %ecx
    496508                rep movsq
    497509               
    498510                /* Clear the 24th row */
    499                 xorq %rax, %rax
    500                 movq $20, %rcx
     511                xorl %eax, %eax
     512                movl $20, %ecx
    501513                rep stosq
    502514               
  • kernel/arch/amd64/src/boot/boot.S

    ra63ff7d r60898b6  
    516516                movq $(PA2KA(0xb80a0)), %rsi
    517517                movq $(PA2KA(0xb8000)), %rdi
    518                 movq $480, %rcx
     518                movl $480, %ecx
    519519                rep movsq
    520520               
    521521                /* Clear the 24th row */
    522                 xorq %rax, %rax
    523                 movq $20, %rcx
     522                xorl %eax, %eax
     523                movl $20, %ecx
    524524                rep stosq
    525525               
  • kernel/arch/amd64/src/context.S

    ra63ff7d r60898b6  
    4545        CONTEXT_SAVE_ARCH_CORE %rdi %rdx
    4646       
    47         xorq %rax, %rax       # context_save returns 1
    48         incq %rax
     47        xorl %eax, %eax       # context_save returns 1
     48        incl %eax
    4949        ret
    5050
     
    6060        movq %rdx, (%rsp)
    6161       
    62         xorq %rax, %rax       # context_restore returns 0
     62        xorl %eax, %eax       # context_restore returns 0
    6363        ret
  • kernel/arch/arm32/include/exception.h

    ra63ff7d r60898b6  
    3939
    4040#include <typedefs.h>
    41 #include <arch/regutils.h>
    42 #include <trace.h>
     41#include <arch/istate.h>
    4342
    4443/** If defined, forces using of high exception vectors. */
     
    8584extern uintptr_t exc_stack;
    8685
    87 /** Struct representing CPU state saved when an exception occurs. */
    88 typedef struct istate {
    89         uint32_t spsr;
    90         uint32_t sp;
    91         uint32_t lr;
    92        
    93         uint32_t r0;
    94         uint32_t r1;
    95         uint32_t r2;
    96         uint32_t r3;
    97         uint32_t r4;
    98         uint32_t r5;
    99         uint32_t r6;
    100         uint32_t r7;
    101         uint32_t r8;
    102         uint32_t r9;
    103         uint32_t r10;
    104         uint32_t fp;
    105         uint32_t r12;
    106        
    107         uint32_t pc;
    108 } istate_t;
    109 
    110 /** Set Program Counter member of given istate structure.
    111  *
    112  * @param istate  istate structure
    113  * @param retaddr new value of istate's PC member
    114  *
    115  */
    116 NO_TRACE static inline void istate_set_retaddr(istate_t *istate,
    117     uintptr_t retaddr)
    118 {
    119         istate->pc = retaddr;
    120 }
    121 
    122 /** Return true if exception happened while in userspace. */
    123 NO_TRACE static inline int istate_from_uspace(istate_t *istate)
    124 {
    125         return (istate->spsr & STATUS_REG_MODE_MASK) == USER_MODE;
    126 }
    127 
    128 /** Return Program Counter member of given istate structure. */
    129 NO_TRACE static inline unative_t istate_get_pc(istate_t *istate)
    130 {
    131         return istate->pc;
    132 }
    133 
    134 NO_TRACE static inline unative_t istate_get_fp(istate_t *istate)
    135 {
    136         return istate->fp;
    137 }
    138 
    13986extern void install_exception_handlers(void);
    14087extern void exception_init(void);
  • kernel/arch/ia32/include/interrupt.h

    ra63ff7d r60898b6  
    3737
    3838#include <typedefs.h>
     39#include <arch/istate.h>
    3940#include <arch/pm.h>
    40 #include <trace.h>
    4141
    4242#define IVT_ITEMS  IDT_ITEMS
     
    7171#define VECTOR_DEBUG_IPI          (IVT_FREEBASE + 2)
    7272
    73 typedef struct istate {
    74         /*
    75          * The strange order of the GPRs is given by the requirement to use the
    76          * istate structure for both regular interrupts and exceptions as well
    77          * as for syscall handlers which use this order as an optimization.
    78          */
    79         uint32_t edx;
    80         uint32_t ecx;
    81         uint32_t ebx;
    82         uint32_t esi;
    83         uint32_t edi;
    84         uint32_t ebp;
    85         uint32_t eax;
    86        
    87         uint32_t ebp_frame;  /* imitation of frame pointer linkage */
    88         uint32_t eip_frame;  /* imitation of return address linkage */
    89        
    90         uint32_t gs;
    91         uint32_t fs;
    92         uint32_t es;
    93         uint32_t ds;
    94        
    95         uint32_t error_word;  /* real or fake error word */
    96         uint32_t eip;
    97         uint32_t cs;
    98         uint32_t eflags;
    99         uint32_t esp;         /* only if istate_t is from uspace */
    100         uint32_t ss;          /* only if istate_t is from uspace */
    101 } istate_t;
    102 
    103 /** Return true if exception happened while in userspace */
    104 NO_TRACE static inline int istate_from_uspace(istate_t *istate)
    105 {
    106         return !(istate->eip & 0x80000000);
    107 }
    108 
    109 NO_TRACE static inline void istate_set_retaddr(istate_t *istate,
    110     uintptr_t retaddr)
    111 {
    112         istate->eip = retaddr;
    113 }
    114 
    115 NO_TRACE static inline unative_t istate_get_pc(istate_t *istate)
    116 {
    117         return istate->eip;
    118 }
    119 
    120 NO_TRACE static inline unative_t istate_get_fp(istate_t *istate)
    121 {
    122         return istate->ebp;
    123 }
    124 
    12573extern void (* disable_irqs_function)(uint16_t);
    12674extern void (* enable_irqs_function)(uint16_t);
  • kernel/arch/ia64/include/interrupt.h

    ra63ff7d r60898b6  
    3737
    3838#include <typedefs.h>
    39 #include <arch/register.h>
    40 #include <trace.h>
     39#include <arch/istate.h>
    4140
    4241/** ia64 has 256 INRs. */
     
    7473#define EOI  0  /**< The actual value doesn't matter. */
    7574
    76 typedef struct istate {
    77         uint128_t f2;
    78         uint128_t f3;
    79         uint128_t f4;
    80         uint128_t f5;
    81         uint128_t f6;
    82         uint128_t f7;
    83         uint128_t f8;
    84         uint128_t f9;
    85         uint128_t f10;
    86         uint128_t f11;
    87         uint128_t f12;
    88         uint128_t f13;
    89         uint128_t f14;
    90         uint128_t f15;
    91         uint128_t f16;
    92         uint128_t f17;
    93         uint128_t f18;
    94         uint128_t f19;
    95         uint128_t f20;
    96         uint128_t f21;
    97         uint128_t f22;
    98         uint128_t f23;
    99         uint128_t f24;
    100         uint128_t f25;
    101         uint128_t f26;
    102         uint128_t f27;
    103         uint128_t f28;
    104         uint128_t f29;
    105         uint128_t f30;
    106         uint128_t f31;
    107        
    108         uintptr_t ar_bsp;
    109         uintptr_t ar_bspstore;
    110         uintptr_t ar_bspstore_new;
    111         uint64_t ar_rnat;
    112         uint64_t ar_ifs;
    113         uint64_t ar_pfs;
    114         uint64_t ar_rsc;
    115         uintptr_t cr_ifa;
    116         cr_isr_t cr_isr;
    117         uintptr_t cr_iipa;
    118         psr_t cr_ipsr;
    119         uintptr_t cr_iip;
    120         uint64_t pr;
    121         uintptr_t sp;
    122        
    123         /*
    124          * The following variables are defined only for break_instruction
    125          * handler.
    126          */
    127         uint64_t in0;
    128         uint64_t in1;
    129         uint64_t in2;
    130         uint64_t in3;
    131         uint64_t in4;
    132         uint64_t in5;
    133         uint64_t in6;
    134 } istate_t;
    135 
    13675extern void *ivt;
    137 
    138 NO_TRACE static inline void istate_set_retaddr(istate_t *istate,
    139     uintptr_t retaddr)
    140 {
    141         istate->cr_iip = retaddr;
    142         istate->cr_ipsr.ri = 0;    /* return to instruction slot #0 */
    143 }
    144 
    145 NO_TRACE static inline unative_t istate_get_pc(istate_t *istate)
    146 {
    147         return istate->cr_iip;
    148 }
    149 
    150 NO_TRACE static inline unative_t istate_get_fp(istate_t *istate)
    151 {
    152         /* FIXME */
    153        
    154         return 0;
    155 }
    156 
    157 NO_TRACE static inline int istate_from_uspace(istate_t *istate)
    158 {
    159         return (istate->cr_iip) < 0xe000000000000000ULL;
    160 }
    16176
    16277extern void general_exception(uint64_t, istate_t *);
  • kernel/arch/ia64/include/register.h

    ra63ff7d r60898b6  
    142142#ifndef __ASM__
    143143
     144#ifdef KERNEL
    144145#include <typedefs.h>
     146#else
     147#include <sys/types.h>
     148#endif
    145149
    146150/** Processor Status Register. */
  • kernel/arch/mips32/include/cp0.h

    ra63ff7d r60898b6  
    3636#define KERN_mips32_CP0_H_
    3737
     38#ifdef KERNEL
    3839#include <typedefs.h>
     40#else
     41#include <sys/types.h>
     42#endif
    3943
    4044#define cp0_status_ie_enabled_bit     (1 << 0)
  • kernel/arch/mips32/include/exception.h

    ra63ff7d r60898b6  
    3737
    3838#include <typedefs.h>
    39 #include <arch/cp0.h>
    40 #include <trace.h>
     39#include <arch/istate.h>
    4140
    4241#define EXC_Int    0
     
    5958#define EXC_VCED   31
    6059
    61 typedef struct istate {
    62         /*
    63          * The first seven registers are arranged so that the istate structure
    64          * can be used both for exception handlers and for the syscall handler.
    65          */
    66         uint32_t a0;    /* arg1 */
    67         uint32_t a1;    /* arg2 */
    68         uint32_t a2;    /* arg3 */
    69         uint32_t a3;    /* arg4 */
    70         uint32_t t0;    /* arg5 */
    71         uint32_t t1;    /* arg6 */
    72         uint32_t v0;    /* arg7 */
    73         uint32_t v1;
    74         uint32_t at;
    75         uint32_t t2;
    76         uint32_t t3;
    77         uint32_t t4;
    78         uint32_t t5;
    79         uint32_t t6;
    80         uint32_t t7;
    81         uint32_t s0;
    82         uint32_t s1;
    83         uint32_t s2;
    84         uint32_t s3;
    85         uint32_t s4;
    86         uint32_t s5;
    87         uint32_t s6;
    88         uint32_t s7;
    89         uint32_t t8;
    90         uint32_t t9;
    91         uint32_t kt0;
    92         uint32_t kt1;   /* We use it as thread-local pointer */
    93         uint32_t gp;
    94         uint32_t sp;
    95         uint32_t s8;
    96         uint32_t ra;
    97        
    98         uint32_t lo;
    99         uint32_t hi;
    100        
    101         uint32_t status;        /* cp0_status */
    102         uint32_t epc;           /* cp0_epc */
    103 
    104         uint32_t alignment;     /* to make sizeof(istate_t) a multiple of 8 */
    105 } istate_t;
    106 
    107 NO_TRACE static inline void istate_set_retaddr(istate_t *istate,
    108     uintptr_t retaddr)
    109 {
    110         istate->epc = retaddr;
    111 }
    112 
    113 /** Return true if exception happened while in userspace */
    114 NO_TRACE static inline int istate_from_uspace(istate_t *istate)
    115 {
    116         return istate->status & cp0_status_um_bit;
    117 }
    118 
    119 NO_TRACE static inline unative_t istate_get_pc(istate_t *istate)
    120 {
    121         return istate->epc;
    122 }
    123 
    124 NO_TRACE static inline unative_t istate_get_fp(istate_t *istate)
    125 {
    126         return istate->sp;
    127 }
    128 
    12960extern void exception(istate_t *istate);
    13061extern void tlb_refill_entry(void);
  • kernel/arch/sparc64/include/interrupt.h

    ra63ff7d r60898b6  
    3838
    3939#include <typedefs.h>
    40 #include <arch/regdef.h>
    41 #include <trace.h>
     40#include <arch/istate.h>
    4241
    4342#define IVT_ITEMS  15
     
    5150};
    5251
    53 typedef struct istate {
    54         uint64_t tnpc;
    55         uint64_t tpc;
    56         uint64_t tstate;
    57 } istate_t;
    58 
    59 NO_TRACE static inline void istate_set_retaddr(istate_t *istate,
    60     uintptr_t retaddr)
    61 {
    62         istate->tpc = retaddr;
    63 }
    64 
    65 NO_TRACE static inline int istate_from_uspace(istate_t *istate)
    66 {
    67         return !(istate->tstate & TSTATE_PRIV_BIT);
    68 }
    69 
    70 NO_TRACE static inline unative_t istate_get_pc(istate_t *istate)
    71 {
    72         return istate->tpc;
    73 }
    74 
    75 NO_TRACE static inline unative_t istate_get_fp(istate_t *istate)
    76 {
    77         /* TODO */
    78        
    79         return 0;
    80 }
    81 
    8252#endif
    8353
  • kernel/generic/src/ipc/kbox.c

    ra63ff7d r60898b6  
    107107                /* Terminate debugging session (if any). */
    108108                LOG("Terminate debugging session.");
    109                 irq_spinlock_lock(&TASK->lock, true);
     109                mutex_lock(&TASK->udebug.lock);
    110110                udebug_task_cleanup(TASK);
    111                 irq_spinlock_unlock(&TASK->lock, true);
     111                mutex_unlock(&TASK->udebug.lock);
    112112        } else {
    113113                LOG("Was not debugger.");
  • kernel/tools/amd64/decpt.py

    ra63ff7d r60898b6  
    77def main():
    88    if len(sys.argv) != 2 or not sys.argv[1].startswith('0x'):
    9         print "%s 0x..." % sys.argv[0]
     9        print("%s 0x..." % sys.argv[0])
    1010        sys.exit(1)
    1111   
     
    1616    ptl1 = (address >> 30) & 0x1ff
    1717    ptl0 = (address >> 39) & 0x1ff
    18     print "Ptl0:   %3d" % ptl0
    19     print "Ptl1:   %3d" % ptl1
    20     print "Ptl2:   %3d" % ptl2
    21     print "Ptl3:   %3d" % ptl3
    22     print "Offset: 0x%x" % offset
     18    print("Ptl0:   %3d" % ptl0)
     19    print("Ptl1:   %3d" % ptl1)
     20    print("Ptl2:   %3d" % ptl2)
     21    print("Ptl3:   %3d" % ptl3)
     22    print("Offset: 0x%x" % offset)
    2323
    2424if __name__ == '__main__':
  • kernel/tools/genmap.py

    ra63ff7d r60898b6  
    8686        obdump = read_obdump(obmapf)
    8787       
    88         def sorter(x,y):
    89                 return cmp(x[0],y[0])
     88        def key_sorter(x):
     89                return x[0]
    9090       
    9191        for line in kmapf:
     
    9393                res = startfile.match(line)
    9494               
    95                 if ((res) and (obdump[res.group(1)].has_key(res.group(3)))):
     95                if ((res) and (res.group(3) in obdump[res.group(1)])):
    9696                        offset = int(res.group(2), 16)
    9797                        fname = res.group(3)
    9898                        symbols = obdump[res.group(1)][fname]
    99                         symbols.sort(sorter)
     99                        symbols.sort(key = key_sorter)
    100100                        for addr, symbol in symbols:
    101101                                value = fname + ':' + symbol
     
    107107def main():
    108108        if (len(sys.argv) != 4):
    109                 print "Usage: %s <kernel.map> <nm dump> <output.bin>" % sys.argv[0]
     109                print("Usage: %s <kernel.map> <nm dump> <output.bin>" % sys.argv[0])
    110110                return 1
    111111       
    112112        kmapf = open(sys.argv[1], 'r')
    113113        obmapf = open(sys.argv[2], 'r')
    114         out = open(sys.argv[3], 'w')
     114        out = open(sys.argv[3], 'wb')
    115115       
    116116        generate(kmapf, obmapf, out)
  • kernel/tools/ia32/decpt.py

    ra63ff7d r60898b6  
    77def main():
    88    if len(sys.argv) != 2 or not sys.argv[1].startswith('0x'):
    9         print "%s 0x..." % sys.argv[0]
     9        print("%s 0x..." % sys.argv[0])
    1010        sys.exit(1)
    1111   
     
    1414    ptl1 = (address >> 12) & 0x3ff
    1515    ptl0 = (address >> 22) & 0x3ff
    16     print "Ptl0:   %3d" % ptl0
    17     print "Ptl1:   %3d" % ptl1
    18     print "Offset: 0x%x" % offset
     16    print("Ptl0:   %3d" % ptl0)
     17    print("Ptl1:   %3d" % ptl1)
     18    print("Offset: 0x%x" % offset)
    1919
    2020if __name__ == '__main__':
Note: See TracChangeset for help on using the changeset viewer.