Changeset 99d6fd0 in mainline for kernel/arch/ia32


Ignore:
Timestamp:
2009-03-13T12:57:15Z (17 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
421c833
Parents:
0160b1c8
Message:

cleanup pm.h and related stuff (no change in functionality)

Location:
kernel/arch/ia32
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/ia32/include/cpu.h

    r0160b1c8 r99d6fd0  
    5656        unsigned int model;
    5757        unsigned int stepping;
    58         struct tss *tss;
     58        tss_t *tss;
    5959       
    6060        count_t iomapver_copy;  /** Copy of TASK's I/O Permission bitmap generation count. */
  • kernel/arch/ia32/include/pm.h

    r0160b1c8 r99d6fd0  
    2727 */
    2828
    29 /** @addtogroup ia32   
     29/** @addtogroup ia32
    3030 * @{
    3131 */
     
    3636#define KERN_ia32_PM_H_
    3737
    38 #define IDT_ITEMS       64     
    39 #define GDT_ITEMS       7
     38#define IDT_ITEMS  64
     39#define GDT_ITEMS  7
    4040
    41 #define VESA_INIT_SEGMENT 0x8000
    42 
    43 #define NULL_DES        0
    44 #define KTEXT_DES       1
    45 #define KDATA_DES       2
    46 #define UTEXT_DES       3
    47 #define UDATA_DES       4
    48 #define TSS_DES         5
    49 #define TLS_DES         6 /* Pointer to Thread-Local-Storage data */
     41#define NULL_DES   0
     42#define KTEXT_DES  1
     43#define KDATA_DES  2
     44#define UTEXT_DES  3
     45#define UDATA_DES  4
     46#define TSS_DES    5
     47#define TLS_DES    6  /* Pointer to Thread-Local-Storage data */
    5048
    5149#ifdef CONFIG_FB
    5250
    53 #define VESA_INIT_SEGMENT 0x8000
    54 #define VESA_INIT_DES 7
     51#define VESA_INIT_SEGMENT  0x8000
     52#define VESA_INIT_DES      7
     53#define KTEXT32_DES        KTEXT_DES
     54
    5555#undef GDT_ITEMS
    56 #define GDT_ITEMS 8
     56#define GDT_ITEMS  8
    5757
    5858#endif /* CONFIG_FB */
    5959
     60#define gdtselector(des)  ((des) << 3)
    6061
    61 #define gdtselector(des)        ((des) << 3)
     62#define PL_KERNEL  0
     63#define PL_USER    3
    6264
    63 #define PL_KERNEL       0
    64 #define PL_USER         3
     65#define AR_PRESENT    (1 << 7)
     66#define AR_DATA       (2 << 3)
     67#define AR_CODE       (3 << 3)
     68#define AR_WRITABLE   (1 << 1)
     69#define AR_INTERRUPT  (0x0e)
     70#define AR_TSS        (0x09)
    6571
    66 #define AR_PRESENT      (1 << 7)
    67 #define AR_DATA         (2 << 3)
    68 #define AR_CODE         (3 << 3)
    69 #define AR_WRITABLE     (1 << 1)
    70 #define AR_INTERRUPT    (0xe)
    71 #define AR_TSS          (0x9)
     72#define DPL_KERNEL  (PL_KERNEL << 5)
     73#define DPL_USER    (PL_USER << 5)
    7274
    73 #define DPL_KERNEL      (PL_KERNEL << 5)
    74 #define DPL_USER        (PL_USER << 5)
     75#define TSS_BASIC_SIZE  104
     76#define TSS_IOMAP_SIZE  (16 * 1024 + 1)  /* 16K for bitmap + 1 terminating byte for convenience */
    7577
    76 #define TSS_BASIC_SIZE  104
    77 #define TSS_IOMAP_SIZE  (16 * 1024 + 1) /* 16K for bitmap + 1 terminating byte for convenience */
    78 
    79 #define IO_PORTS        (64 * 1024)
     78#define IO_PORTS  (64 * 1024)
    8079
    8180#ifndef __ASM__
     
    8483#include <arch/context.h>
    8584
    86 struct ptr_16_32 {
     85typedef struct {
    8786        uint16_t limit;
    8887        uint32_t base;
    89 } __attribute__ ((packed));
    90 typedef struct ptr_16_32 ptr_16_32_t;
     88} __attribute__ ((packed)) ptr_16_32_t;
    9189
    92 struct descriptor {
     90typedef struct {
    9391        unsigned limit_0_15: 16;
    9492        unsigned base_0_15: 16;
     
    10199        unsigned granularity : 1;
    102100        unsigned base_24_31: 8;
    103 } __attribute__ ((packed));
    104 typedef struct descriptor  descriptor_t;
     101} __attribute__ ((packed)) descriptor_t;
    105102
    106 struct idescriptor {
     103typedef struct {
    107104        unsigned offset_0_15: 16;
    108105        unsigned selector: 16;
     
    110107        unsigned access: 8;
    111108        unsigned offset_16_31: 16;
    112 } __attribute__ ((packed));
    113 typedef struct idescriptor idescriptor_t;
     109} __attribute__ ((packed)) idescriptor_t;
    114110
    115 struct tss {
     111typedef struct {
    116112        uint16_t link;
    117113        unsigned : 16;
     
    153149        uint16_t iomap_base;
    154150        uint8_t iomap[TSS_IOMAP_SIZE];
    155 } __attribute__ ((packed));
    156 typedef struct tss tss_t;
     151} __attribute__ ((packed)) tss_t;
    157152
    158153extern ptr_16_32_t gdtr;
    159154extern ptr_16_32_t bootstrap_gdtr;
    160155extern ptr_16_32_t protected_ap_gdtr;
    161 extern struct tss *tss_p;
     156extern tss_t *tss_p;
    162157
    163158extern descriptor_t gdt[];
  • kernel/arch/ia32/src/pm.c

    r0160b1c8 r99d6fd0  
    113113void tss_initialize(tss_t *t)
    114114{
    115         memsetb(t, sizeof(struct tss), 0);
     115        memsetb(t, sizeof(tss_t), 0);
    116116}
    117117
  • kernel/arch/ia32/src/proc/scheduler.c

    r0160b1c8 r99d6fd0  
    6060        uintptr_t kstk = (uintptr_t) &THREAD->kstack[THREAD_STACK_SIZE -
    6161            SP_DELTA];
    62 
     62       
    6363        /* Set kernel stack for CP3 -> CPL0 switch via SYSENTER */
    6464        write_msr(IA32_MSR_SYSENTER_ESP, kstk);
    65 
     65       
    6666        /* Set kernel stack for CPL3 -> CPL0 switch via interrupt */
    6767        CPU->arch.tss->esp0 = kstk;
    6868        CPU->arch.tss->ss0 = gdtselector(KDATA_DES);
    69 
     69       
    7070        /* Set up TLS in GS register */
    7171        set_tls_desc(THREAD->arch.tls);
  • kernel/arch/ia32/src/smp/smp.c

    r0160b1c8 r99d6fd0  
    2727 */
    2828
    29 /** @addtogroup ia32   
     29/** @addtogroup ia32
    3030 * @{
    3131 */
     
    132132
    133133        for (i = 0; i < ops->cpu_count(); i++) {
    134                 struct descriptor *gdt_new;
    135        
     134                descriptor_t *gdt_new;
     135               
    136136                /*
    137137                 * Skip processors marked unusable.
     
    160160                 * the memory subsystem
    161161                 */
    162                 gdt_new = (struct descriptor *) malloc(GDT_ITEMS *
    163                     sizeof(struct descriptor), FRAME_ATOMIC);
     162                gdt_new = (descriptor_t *) malloc(GDT_ITEMS *
     163                    sizeof(descriptor_t), FRAME_ATOMIC);
    164164                if (!gdt_new)
    165165                        panic("Cannot allocate memory for GDT.");
    166166
    167                 memcpy(gdt_new, gdt, GDT_ITEMS * sizeof(struct descriptor));
    168                 memsetb(&gdt_new[TSS_DES], sizeof(struct descriptor), 0);
    169                 protected_ap_gdtr.limit = GDT_ITEMS * sizeof(struct descriptor);
     167                memcpy(gdt_new, gdt, GDT_ITEMS * sizeof(descriptor_t));
     168                memsetb(&gdt_new[TSS_DES], sizeof(descriptor_t), 0);
     169                protected_ap_gdtr.limit = GDT_ITEMS * sizeof(descriptor_t);
    170170                protected_ap_gdtr.base = KA2PA((uintptr_t) gdt_new);
    171171                gdtr.base = (uintptr_t) gdt_new;
Note: See TracChangeset for help on using the changeset viewer.