Changeset 0f17bff in mainline for kernel/arch/ia32/src


Ignore:
Timestamp:
2016-05-05T08:34:45Z (9 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
811770c
Parents:
4b0206c
Message:

Replace magic numbers with macros

Location:
kernel/arch/ia32/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/ia32/src/asm.S

    r4b0206c r0f17bff  
    3636#include <arch/mm/page.h>
    3737#include <arch/istate_struct.h>
     38#include <arch/smp/apic.h>
    3839
    3940.text
     
    110111FUNCTION_BEGIN(paging_on)
    111112        movl %cr0, %edx
    112         orl $(1 << 31), %edx  /* paging on */
     113        orl $CR0_PG, %edx  /* paging on */
    113114       
    114115        /* Clear Cache Disable and not Write Though */
    115         andl $~((1 << 30) | (1 << 29)), %edx
     116        andl $~(CR0_CD | CR0_NW), %edx
    116117        movl %edx, %cr0
    117118        jmp 0f
     
    127128 */
    128129FUNCTION_BEGIN(enable_l_apic_in_msr)
    129         movl $0x1b, %ecx
     130        movl $IA32_MSR_APIC_BASE, %ecx
    130131        rdmsr
    131         orl $(1 << 11), %eax
    132         orl $(0xfee00000), %eax
     132        orl $(L_APIC_BASE | IA32_APIC_BASE_GE), %eax
    133133        wrmsr
    134134        ret
  • kernel/arch/ia32/src/pm.c

    r4b0206c r0f17bff  
    4747#include <arch/boot/boot.h>
    4848#include <interrupt.h>
     49#include <arch/cpu.h>
    4950
    5051/*
     
    256257}
    257258
    258 /* Clean IOPL(12,13) and NT(14) flags in EFLAGS register */
    259 static void clean_IOPL_NT_flags(void)
    260 {
    261         asm volatile (
    262                 "pushfl\n"
    263                 "pop %%eax\n"
    264                 "and $0xffff8fff, %%eax\n"
    265                 "push %%eax\n"
    266                 "popfl\n"
    267                 ::: "eax"
    268         );
    269 }
    270 
    271 /* Clean AM(18) flag in CR0 register */
    272 static void clean_AM_flag(void)
    273 {
    274         asm volatile (
    275                 "mov %%cr0, %%eax\n"
    276                 "and $0xfffbffff, %%eax\n"
    277                 "mov %%eax, %%cr0\n"
    278                 ::: "eax"
    279         );
    280 }
    281 
    282259void pm_init(void)
    283260{
     
    326303        tr_load(GDT_SELECTOR(TSS_DES));
    327304       
    328         clean_IOPL_NT_flags();    /* Disable I/O on nonprivileged levels and clear NT flag. */
    329         clean_AM_flag();          /* Disable alignment check */
     305        /* Disable I/O on nonprivileged levels and clear NT flag. */
     306        write_eflags(read_eflags() & ~(EFLAGS_IOPL | EFLAGS_NT));
     307
     308        /* Disable alignment check */
     309        write_cr0(read_cr0() & ~CR0_AM);
    330310}
    331311
  • kernel/arch/ia32/src/smp/apic.c

    r4b0206c r0f17bff  
    7272 *
    7373 */
    74 volatile uint32_t *l_apic = (uint32_t *) UINT32_C(0xfee00000);
    75 volatile uint32_t *io_apic = (uint32_t *) UINT32_C(0xfec00000);
     74volatile uint32_t *l_apic = (uint32_t *) L_APIC_BASE;
     75volatile uint32_t *io_apic = (uint32_t *) IO_APIC_BASE;
    7676
    7777uint32_t apic_id_mask = 0;
  • kernel/arch/ia32/src/userspace.c

    r4b0206c r0f17bff  
    3939#include <abi/proc/uarg.h>
    4040#include <mm/as.h>
     41#include <arch/cpu.h>
     42#include <arch/asm.h>
    4143
    4244/** Enter userspace
     
    4749void userspace(uspace_arg_t *kernel_uarg)
    4850{
    49         ipl_t ipl = interrupts_disable();
     51        uint32_t eflags = read_eflags();
    5052       
    5153        asm volatile (
    52                 /*
    53                  * Clear nested task flag.
    54                  */
    55                 "pushfl\n"
    56                 "pop %%eax\n"
    57                 "and $0xffffbfff, %%eax\n"
    58                 "push %%eax\n"
    59                 "popfl\n"
    60                
    6154                /* Set up GS register (virtual register segment) */
    6255                "movl %[vreg_des], %%gs\n"
     
    6457                "pushl %[udata_des]\n"
    6558                "pushl %[stack_top]\n"
    66                 "pushl %[ipl]\n"
     59                "pushl %[eflags]\n"
    6760                "pushl %[utext_des]\n"
    6861                "pushl %[entry]\n"
     
    7467                "iret\n"
    7568                :
    76                 : [udata_des] "i" (GDT_SELECTOR(UDATA_DES) | PL_USER),
     69                : [eflags_mask] "i" (~EFLAGS_NT),
     70                  [udata_des] "i" (GDT_SELECTOR(UDATA_DES) | PL_USER),
    7771                  [stack_top] "r" ((uint8_t *) kernel_uarg->uspace_stack +
    7872                      kernel_uarg->uspace_stack_size),
    79                   [ipl] "r" (ipl),
     73                  [eflags] "r" ((eflags & ~(EFLAGS_NT)) | EFLAGS_IF),
    8074                  [utext_des] "i" (GDT_SELECTOR(UTEXT_DES) | PL_USER),
    8175                  [entry] "r" (kernel_uarg->uspace_entry),
Note: See TracChangeset for help on using the changeset viewer.