Changeset 1d3d2cf in mainline


Ignore:
Timestamp:
2010-08-11T14:18:34Z (14 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
be3f94c
Parents:
482dde7
Message:

rename gdtselector to GDT_SELECTOR to make explicit it is a macro
unify how bootstrap_gdtr is defined on amd64 and ia32

Location:
kernel/arch
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/amd64/include/pm.h

    r482dde7 r1d3d2cf  
    6565#endif /* CONFIG_FB */
    6666
    67 #define gdtselector(des)  ((des) << 3)
    68 #define idtselector(des)  ((des) << 4)
     67#define GDT_SELECTOR(des)  ((des) << 3)
    6968
    7069#define PL_KERNEL  0
     
    168167
    169168extern ptr_16_64_t gdtr;
    170 extern ptr_16_32_t bootstrap_gdtr;
    171169extern ptr_16_32_t protected_ap_gdtr;
    172170
  • kernel/arch/amd64/src/asm.S

    r482dde7 r1d3d2cf  
    244244         */
    245245        xorq %rdx, %rdx
    246         cmpq $(gdtselector(KTEXT_DES)), ISTATE_OFFSET_CS(%rsp)
     246        cmpq $(GDT_SELECTOR(KTEXT_DES)), ISTATE_OFFSET_CS(%rsp)
    247247        cmovnzq %rdx, %rbp
    248248
  • kernel/arch/amd64/src/boot/boot.S

    r482dde7 r1d3d2cf  
    8585       
    8686        /* Kernel data + stack */
    87         movw $gdtselector(KDATA_DES), %cx
     87        movw $GDT_SELECTOR(KDATA_DES), %cx
    8888        movw %cx, %es
    8989        movw %cx, %ds
     
    9494         * when _visible_ part of GS does not point to user-mode segment.
    9595         */
    96         movw $gdtselector(UDATA_DES), %cx
     96        movw $GDT_SELECTOR(UDATA_DES), %cx
    9797        movw %cx, %fs
    9898        movw %cx, %gs
    9999       
    100         jmpl $gdtselector(KTEXT32_DES), $multiboot_meeting_point
     100        jmpl $GDT_SELECTOR(KTEXT32_DES), $multiboot_meeting_point
    101101        multiboot_meeting_point:
    102102       
     
    182182       
    183183        /* At this point we are in compatibility mode */
    184         jmpl $gdtselector(KTEXT_DES), $start64
     184        jmpl $GDT_SELECTOR(KTEXT_DES), $start64
    185185
    186186/** Print string to EGA display (in light red) and halt.
     
    645645.section K_DATA_START, "aw", @progbits
    646646
    647 .global bootstrap_gdtr
    648647bootstrap_gdtr:
    649         .word gdtselector(GDT_ITEMS)
     648        .word GDT_SELECTOR(GDT_ITEMS)
    650649        .long KA2PA(gdt)
    651650
  • kernel/arch/amd64/src/boot/vesa_ret.inc

    r482dde7 r1d3d2cf  
    77       
    88        /* Kernel data + stack */
    9         movw $gdtselector(KDATA_DES), %cx
     9        movw $GDT_SELECTOR(KDATA_DES), %cx
    1010        movw %cx, %es
    1111        movw %cx, %ds
     
    1717         */
    1818       
    19         movw $gdtselector(UDATA_DES), %cx
     19        movw $GDT_SELECTOR(UDATA_DES), %cx
    2020        movw %cx, %fs
    2121        movw %cx, %gs
    2222       
    23         jmpl $gdtselector(KTEXT32_DES), $vesa_meeting_point
     23        jmpl $GDT_SELECTOR(KTEXT32_DES), $vesa_meeting_point
  • kernel/arch/amd64/src/ddi/ddi.c

    r482dde7 r1d3d2cf  
    153153        tss_descriptor_t *tss_desc = (tss_descriptor_t *) &gdt_p[TSS_DES];
    154154        tss_desc->type = AR_TSS;
    155         tr_load(gdtselector(TSS_DES));
     155        tr_load(GDT_SELECTOR(TSS_DES));
    156156       
    157157        /*
  • kernel/arch/amd64/src/pm.c

    r482dde7 r1d3d2cf  
    171171
    172172                d->unused = 0;
    173                 d->selector = gdtselector(KTEXT_DES);
     173                d->selector = GDT_SELECTOR(KTEXT_DES);
    174174
    175175                d->present = 1;
     
    291291         * to its own TSS. We just need to load the TR register.
    292292         */
    293         tr_load(gdtselector(TSS_DES));
     293        tr_load(GDT_SELECTOR(TSS_DES));
    294294}
    295295
  • kernel/arch/amd64/src/smp/ap.S

    r482dde7 r1d3d2cf  
    6161        orl $1, %eax
    6262        movl %eax, %cr0     # switch to protected mode
    63         jmpl $gdtselector(KTEXT32_DES), $jump_to_kernel - BOOT_OFFSET + AP_BOOT_OFFSET
     63        jmpl $GDT_SELECTOR(KTEXT32_DES), $jump_to_kernel - BOOT_OFFSET + AP_BOOT_OFFSET
    6464
    6565jump_to_kernel:
    6666.code32
    67         movw $gdtselector(KDATA_DES), %ax
     67        movw $GDT_SELECTOR(KDATA_DES), %ax
    6868        movw %ax, %ds
    6969        movw %ax, %es
    7070        movw %ax, %ss
    71         movw $gdtselector(UDATA_DES), %ax
     71        movw $GDT_SELECTOR(UDATA_DES), %ax
    7272        movw %ax, %gs
    7373       
     
    9494       
    9595        # At this point we are in compatibility mode
    96         jmpl $gdtselector(KTEXT_DES), $start64 - BOOT_OFFSET + AP_BOOT_OFFSET
     96        jmpl $GDT_SELECTOR(KTEXT_DES), $start64 - BOOT_OFFSET + AP_BOOT_OFFSET
    9797
    9898.code64
  • kernel/arch/amd64/src/syscall.c

    r482dde7 r1d3d2cf  
    5858         */
    5959        write_msr(AMD_MSR_STAR,
    60             ((uint64_t)(gdtselector(KDATA_DES) | PL_USER) << 48) |
    61             ((uint64_t)(gdtselector(KTEXT_DES) | PL_KERNEL) << 32));
     60            ((uint64_t) (GDT_SELECTOR(KDATA_DES) | PL_USER) << 48) |
     61            ((uint64_t) (GDT_SELECTOR(KTEXT_DES) | PL_KERNEL) << 32));
    6262        write_msr(AMD_MSR_LSTAR, (uint64_t)syscall_entry);
    6363        /* Mask RFLAGS on syscall
  • kernel/arch/amd64/src/userspace.c

    r482dde7 r1d3d2cf  
    6565                "xorq %%rdi, %%rdi\n"
    6666                "iretq\n"
    67                 :: [udata_des] "i" (gdtselector(UDATA_DES) | PL_USER),
     67                :: [udata_des] "i" (GDT_SELECTOR(UDATA_DES) | PL_USER),
    6868                   [stack_size] "r" (kernel_uarg->uspace_stack + THREAD_STACK_SIZE),
    6969                   [ipl] "r" (ipl),
    70                    [utext_des] "i" (gdtselector(UTEXT_DES) | PL_USER),
     70                   [utext_des] "i" (GDT_SELECTOR(UTEXT_DES) | PL_USER),
    7171                   [entry] "r" (kernel_uarg->uspace_entry),
    7272                   [uarg] "r" (kernel_uarg->uspace_uarg)
  • kernel/arch/ia32/include/pm.h

    r482dde7 r1d3d2cf  
    5858#endif /* CONFIG_FB */
    5959
    60 #define gdtselector(des)  ((des) << 3)
     60#define GDT_SELECTOR(des)  ((des) << 3)
    6161
    6262#define PL_KERNEL  0
     
    153153
    154154extern ptr_16_32_t gdtr;
    155 extern ptr_16_32_t bootstrap_gdtr;
    156155extern ptr_16_32_t protected_ap_gdtr;
    157156extern tss_t *tss_p;
  • kernel/arch/ia32/src/asm.S

    r482dde7 r1d3d2cf  
    225225         * Switch to kernel selectors.
    226226         */
    227         movw $(gdtselector(KDATA_DES)), %ax
     227        movw $(GDT_SELECTOR(KDATA_DES)), %ax
    228228        movw %ax, %ds
    229229        movw %ax, %es
     
    304304         * Switch to kernel selectors.
    305305         */
    306         movl $(gdtselector(KDATA_DES)), %eax
     306        movl $(GDT_SELECTOR(KDATA_DES)), %eax
    307307        movl %eax, %ds
    308308        movl %eax, %es
     
    407407         * Switch to kernel selectors.
    408408         */
    409         movl $(gdtselector(KDATA_DES)), %eax
     409        movl $(GDT_SELECTOR(KDATA_DES)), %eax
    410410        movl %eax, %ds
    411411        movl %eax, %es
     
    416416         */
    417417        xorl %eax, %eax
    418         cmpl $(gdtselector(KTEXT_DES)), ISTATE_OFFSET_CS(%esp)
     418        cmpl $(GDT_SELECTOR(KTEXT_DES)), ISTATE_OFFSET_CS(%esp)
    419419        cmovnzl %eax, %ebp
    420420
  • kernel/arch/ia32/src/boot/boot.S

    r482dde7 r1d3d2cf  
    7878       
    7979        /* Initialize Global Descriptor Table register */
    80         lgdtl KA2PA(bootstrap_gdtr)
     80        lgdtl bootstrap_gdtr
    8181       
    8282        /* Kernel data + stack */
    83         movw $gdtselector(KDATA_DES), %cx
     83        movw $GDT_SELECTOR(KDATA_DES), %cx
    8484        movw %cx, %es
    8585        movw %cx, %fs
     
    8888        movw %cx, %ss
    8989       
    90         jmpl $gdtselector(KTEXT_DES), $multiboot_meeting_point
     90        jmpl $GDT_SELECTOR(KTEXT_DES), $multiboot_meeting_point
    9191        multiboot_meeting_point:
    9292       
     
    514514page_directory:
    515515        .space 4096, 0
     516
     517bootstrap_gdtr:
     518        .word GDT_SELECTOR(GDT_ITEMS)
     519        .long KA2PA(gdt)
    516520
    517521grub_eax:
  • kernel/arch/ia32/src/boot/vesa_real.inc

    r482dde7 r1d3d2cf  
    3030.code32
    3131vesa_init:
    32         jmp $gdtselector(VESA_INIT_DES), $vesa_init_real - vesa_init
     32        jmp $GDT_SELECTOR(VESA_INIT_DES), $vesa_init_real - vesa_init
    3333
    3434.code16
     
    335335                vesa_leave_real2:
    336336               
    337                         ljmpl $gdtselector(KTEXT32_DES), $(vesa_init_protected - vesa_init + VESA_INIT_SEGMENT << 4)
     337                        ljmpl $GDT_SELECTOR(KTEXT32_DES), $(vesa_init_protected - vesa_init + VESA_INIT_SEGMENT << 4)
    338338       
    339339        no_mode:
  • kernel/arch/ia32/src/boot/vesa_ret.inc

    r482dde7 r1d3d2cf  
    77       
    88        /* Kernel data + stack */
    9         movw $gdtselector(KDATA_DES), %cx
     9        movw $GDT_SELECTOR(KDATA_DES), %cx
    1010        movw %cx, %es
    1111        movw %cx, %fs
     
    1414        movw %cx, %ss
    1515       
    16         jmpl $gdtselector(KTEXT_DES), $vesa_meeting_point
     16        jmpl $GDT_SELECTOR(KTEXT_DES), $vesa_meeting_point
  • kernel/arch/ia32/src/ddi/ddi.c

    r482dde7 r1d3d2cf  
    153153         */
    154154        gdt_p[TSS_DES].access = AR_PRESENT | AR_TSS | DPL_KERNEL;
    155         tr_load(gdtselector(TSS_DES));
     155        tr_load(GDT_SELECTOR(TSS_DES));
    156156       
    157157        /*
  • kernel/arch/ia32/src/pm.c

    r482dde7 r1d3d2cf  
    8686
    8787/* gdtr is changed by kmp before next CPU is initialized */
    88 ptr_16_32_t bootstrap_gdtr = { .limit = sizeof(gdt), .base = KA2PA((uintptr_t) gdt) };
    8988ptr_16_32_t gdtr = { .limit = sizeof(gdt), .base = (uintptr_t) gdt };
    9089
     
    128127
    129128                d->unused = 0;
    130                 d->selector = gdtselector(KTEXT_DES);
     129                d->selector = GDT_SELECTOR(KTEXT_DES);
    131130
    132131                if (i == VECTOR_SYSCALL) {
     
    283282         * to its own TSS. We just need to load the TR register.
    284283         */
    285         tr_load(gdtselector(TSS_DES));
     284        tr_load(GDT_SELECTOR(TSS_DES));
    286285       
    287286        clean_IOPL_NT_flags();    /* Disable I/O on nonprivileged levels and clear NT flag. */
  • kernel/arch/ia32/src/proc/scheduler.c

    r482dde7 r1d3d2cf  
    6767        /* Set kernel stack for CPL3 -> CPL0 switch via interrupt */
    6868        CPU->arch.tss->esp0 = kstk;
    69         CPU->arch.tss->ss0 = gdtselector(KDATA_DES);
     69        CPU->arch.tss->ss0 = GDT_SELECTOR(KDATA_DES);
    7070       
    7171        /* Set up TLS in GS register */
  • kernel/arch/ia32/src/syscall.c

    r482dde7 r1d3d2cf  
    4545
    4646        /* set kernel mode CS selector */
    47         write_msr(IA32_MSR_SYSENTER_CS, gdtselector(KTEXT_DES));
     47        write_msr(IA32_MSR_SYSENTER_CS, GDT_SELECTOR(KTEXT_DES));
    4848        /* set kernel mode entry point */
    4949        write_msr(IA32_MSR_SYSENTER_EIP, (uint32_t) sysenter_handler);
  • kernel/arch/ia32/src/userspace.c

    r482dde7 r1d3d2cf  
    7575                "iret\n"
    7676                :
    77                 : [udata_des] "i" (gdtselector(UDATA_DES) | PL_USER),
     77                : [udata_des] "i" (GDT_SELECTOR(UDATA_DES) | PL_USER),
    7878                  [stack_size] "r" ((uint8_t *) kernel_uarg->uspace_stack + THREAD_STACK_SIZE),
    7979                  [ipl] "r" (ipl),
    80                   [utext_des] "i" (gdtselector(UTEXT_DES) | PL_USER),
     80                  [utext_des] "i" (GDT_SELECTOR(UTEXT_DES) | PL_USER),
    8181                  [entry] "r" (kernel_uarg->uspace_entry),
    8282                  [uarg] "r" (kernel_uarg->uspace_uarg),
    83                   [tls_des] "r" (gdtselector(TLS_DES))
     83                  [tls_des] "r" (GDT_SELECTOR(TLS_DES))
    8484                : "eax");
    8585       
Note: See TracChangeset for help on using the changeset viewer.