amd64
[Miscellanea]


Files

file  arch.h
file  arg.h
file  asm.h
file  atomic.h
file  boot.h
file  byteorder.h
file  context.h
file  cpu.h
file  cpuid.h
file  vesa.h
file  elf.h
file  faddr.h
file  memstr.h
file  pm.h
file  syscall.h
file  types.h
file  amd64.c
file  cpu.c
file  fpu_context.c
file  pm.c
file  syscall.c
file  userspace.c

Data Structures

struct  context
struct  cpu_arch
struct  star_msr
struct  lstar_msr
struct  cpu_info
struct  descriptor
struct  tss_descriptor
struct  idescriptor
struct  ptr_16_64
struct  ptr_16_32
struct  tss

Defines

#define GEN_READ_REG(reg)
#define GEN_WRITE_REG(reg)
#define atomic_preinc(val)   (atomic_postinc(val)+1)
#define atomic_predec(val)   (atomic_postdec(val)-1)
#define BOOT_OFFSET   0x108000
#define AP_BOOT_OFFSET   0x8000
#define BOOT_STACK_SIZE   0x400
#define MULTIBOOT_HEADER_MAGIC   0x1BADB002
#define MULTIBOOT_HEADER_FLAGS   0x00010003
#define MULTIBOOT_LOADER_MAGIC   0x2BADB002
#define __native_le2host(n)   (n)
#define __u64_le2host(n)   (n)
#define SP_DELTA   16
#define RFLAGS_IF   (1 << 9)
#define RFLAGS_RF   (1 << 16)
#define EFER_MSR_NUM   0xc0000080
#define AMD_SCE_FLAG   0
#define AMD_LME_FLAG   8
#define AMD_LMA_FLAG   10
#define AMD_FFXSR_FLAG   14
#define AMD_NXE_FLAG   11
#define AMD_MSR_STAR   0xc0000081
#define AMD_MSR_LSTAR   0xc0000082
#define AMD_MSR_SFMASK   0xc0000084
#define AMD_MSR_FS   0xc0000100
#define AMD_MSR_GS   0xc0000101
#define AMD_CPUID_EXTENDED   0x80000001
#define AMD_EXT_NOEXECUTE   20
#define INTEL_CPUID_STANDARD   0x1
#define INTEL_SSE2   26
#define INTEL_FXSAVE   24
#define ELF_MACHINE   EM_X86_64
#define ELF_DATA_ENCODING   ELFDATA2LSB
#define ELF_CLASS   ELFCLASS64
#define FADDR(fptr)   ((__address) (fptr))
#define IDT_ITEMS   64
#define GDT_ITEMS   8
#define NULL_DES   0
#define KTEXT_DES   1
#define KDATA_DES   2
#define UDATA_DES   3
#define UTEXT_DES   4
#define KTEXT32_DES   5
#define TSS_DES   6
#define gdtselector(des)   ((des)<<3)
#define idtselector(des)   ((des)<<4)
#define PL_KERNEL   0
#define PL_USER   3
#define AR_PRESENT   (1<<7)
#define AR_DATA   (2<<3)
#define AR_CODE   (3<<3)
#define AR_WRITABLE   (1<<1)
#define AR_READABLE   (1<<1)
#define AR_TSS   (0x9)
#define AR_INTERRUPT   (0xe)
#define AR_TRAP   (0xf)
#define DPL_KERNEL   (PL_KERNEL<<5)
#define DPL_USER   (PL_USER<<5)
#define TSS_BASIC_SIZE   104
#define TSS_IOMAP_SIZE   (16*1024+1)
#define IO_PORTS   (64*1024)
#define NULL   0
#define AMD_CPUID_EBX   0x68747541
#define AMD_CPUID_ECX   0x444d4163
#define AMD_CPUID_EDX   0x69746e65
#define INTEL_CPUID_EBX   0x756e6547
#define INTEL_CPUID_ECX   0x6c65746e
#define INTEL_CPUID_EDX   0x49656e69

Typedefs

typedef descriptor descriptor_t
typedef tss_descriptor tss_descriptor_t
typedef idescriptor idescriptor_t
typedef ptr_16_64 ptr_16_64_t
typedef ptr_16_32 ptr_16_32_t
typedef tss tss_t
typedef signed char __s8
typedef signed short __s16
typedef signed int __s32
typedef signed long long __s64
typedef unsigned char __u8
typedef unsigned short __u16
typedef unsigned int __u32
typedef unsigned long long __u64
typedef __u64 __address
typedef __u64 pfn_t
typedef __u64 ipl_t
typedef __u64 __native
typedef __s64 __snative
typedef page_specifier pte_t

Enumerations

enum  vendor { VendorUnknown = 0, VendorAMD, VendorIntel }

Functions

void asm_delay_loop (__u32 t)
void asm_fake_loop (__u32 t)
static __address get_stack_base (void)
static void cpu_sleep (void)
static void cpu_halt (void)
static __u8 inb (__u16 port)
static void outb (__u16 port, __u8 val)
static void swapgs (void)
static ipl_t interrupts_enable (void)
static ipl_t interrupts_disable (void)
static void interrupts_restore (ipl_t ipl)
static ipl_t interrupts_read (void)
static void write_msr (__u32 msr, __u64 value)
static __native read_msr (__u32 msr)
static void enable_l_apic_in_msr ()
static __addressget_ip ()
static void invlpg (__address addr)
static void gdtr_load (struct ptr_16_64 *gdtr_reg)
static void gdtr_store (struct ptr_16_64 *gdtr_reg)
static void idtr_load (struct ptr_16_64 *idtr_reg)
static void tr_load (__u16 sel)
 GEN_READ_REG (cr0)
 GEN_READ_REG (cr2)
 GEN_READ_REG (cr3)
 GEN_WRITE_REG (cr3)
 GEN_READ_REG (dr0)
 GEN_READ_REG (dr1)
 GEN_READ_REG (dr2)
 GEN_READ_REG (dr3)
 GEN_READ_REG (dr6)
 GEN_READ_REG (dr7)
 GEN_WRITE_REG (dr0)
 GEN_WRITE_REG (dr1)
 GEN_WRITE_REG (dr2)
 GEN_WRITE_REG (dr3)
 GEN_WRITE_REG (dr6)
 GEN_WRITE_REG (dr7)
void interrupt_handlers (void)
static void atomic_inc (atomic_t *val)
static void atomic_dec (atomic_t *val)
static long atomic_postinc (atomic_t *val)
static long atomic_postdec (atomic_t *val)
static __u64 test_and_set (atomic_t *val)
static void atomic_lock_arch (atomic_t *val)
void set_efer_flag (int flag)
__u64 read_efer_flag (void)
void cpu_setup_fpu (void)
int has_cpuid (void)
void cpuid (__u32 cmd, cpu_info_t *info)
__u64 rdtsc (void)
int vesa_present (void)
void vesa_init (void)
static void * memcpy (void *dst, const void *src, size_t cnt)
static int memcmp (const void *src, const void *dst, size_t cnt)
static void memsetw (__address dst, size_t cnt, __u16 x)
static void memsetb (__address dst, size_t cnt, __u8 x)
void pm_init (void)
void gdt_tss_setbase (descriptor_t *d, __address base)
void gdt_tss_setlimit (descriptor_t *d, __u32 limit)
void idt_init (void)
void idt_setoffset (idescriptor_t *d, __address offset)
void tss_initialize (tss_t *t)
void syscall_setup_cpu (void)
static void clean_IOPL_NT_flags (void)
static void clean_AM_flag (void)
void arch_pre_mm_init (void)
void arch_post_mm_init (void)
void arch_pre_smp_init (void)
void arch_post_smp_init (void)
void calibrate_delay_loop (void)
__native sys_tls_set (__native addr)
void arch_grab_console (void)
void arch_release_console (void)
void fpu_disable (void)
void fpu_enable (void)
void cpu_arch_init (void)
void cpu_identify (void)
void cpu_print_report (cpu_t *m)
void fpu_context_save (fpu_context_t *fctx)
void fpu_context_restore (fpu_context_t *fctx)
void fpu_init ()
void syscall_entry (void)
void userspace (uspace_arg_t *kernel_uarg)

Variables

size_t interrupt_handler_size
context packed
cpu_info packed
descriptor packed
tss_descriptor packed
idescriptor packed
ptr_16_64 packed
ptr_16_32 packed
tss packed
tss_ttss_p
descriptor_t gdt []
idescriptor_t idt []
ptr_16_64_t gdtr
ptr_16_32_t bootstrap_gdtr
ptr_16_32_t protected_ap_gdtr
static char * vendor_str []
descriptor_t gdt [GDT_ITEMS]
idescriptor_t idt [IDT_ITEMS]
ptr_16_64_t gdtr = {.limit = sizeof(gdt), .base= (__u64) gdt }
ptr_16_64_t idtr = {.limit = sizeof(idt), .base= (__u64) idt }
static tss_t tss
tss_ttss_p = NULL

Define Documentation

#define __native_le2host  )     (n)
 

Definition at line 39 of file byteorder.h.

#define __u64_le2host  )     (n)
 

Definition at line 40 of file byteorder.h.

Referenced by get_symbol_addr(), get_symtab_entry(), and symtab_print_search().

#define AMD_CPUID_EBX   0x68747541
 

Definition at line 49 of file cpu.c.

Referenced by cpu_identify().

#define AMD_CPUID_ECX   0x444d4163
 

Definition at line 50 of file cpu.c.

Referenced by cpu_identify().

#define AMD_CPUID_EDX   0x69746e65
 

Definition at line 51 of file cpu.c.

Referenced by cpu_identify().

#define AMD_CPUID_EXTENDED   0x80000001
 

Definition at line 38 of file cpuid.h.

Referenced by arch_pre_mm_init().

#define AMD_EXT_NOEXECUTE   20
 

Definition at line 39 of file cpuid.h.

Referenced by arch_pre_mm_init().

#define AMD_FFXSR_FLAG   14
 

Definition at line 45 of file cpu.h.

#define AMD_LMA_FLAG   10
 

Definition at line 44 of file cpu.h.

#define AMD_LME_FLAG   8
 

Definition at line 43 of file cpu.h.

#define AMD_MSR_FS   0xc0000100
 

Definition at line 52 of file cpu.h.

Referenced by before_thread_runs_arch(), and sys_tls_set().

#define AMD_MSR_GS   0xc0000101
 

Definition at line 53 of file cpu.h.

Referenced by before_thread_runs_arch().

#define AMD_MSR_LSTAR   0xc0000082
 

Definition at line 50 of file cpu.h.

Referenced by syscall_setup_cpu().

#define AMD_MSR_SFMASK   0xc0000084
 

Definition at line 51 of file cpu.h.

Referenced by syscall_setup_cpu().

#define AMD_MSR_STAR   0xc0000081
 

Definition at line 49 of file cpu.h.

Referenced by syscall_setup_cpu().

#define AMD_NXE_FLAG   11
 

Definition at line 46 of file cpu.h.

Referenced by arch_pre_mm_init().

#define AMD_SCE_FLAG   0
 

Definition at line 42 of file cpu.h.

Referenced by syscall_setup_cpu().

#define AP_BOOT_OFFSET   0x8000
 

Definition at line 39 of file boot.h.

#define AR_CODE   (3<<3)
 

Definition at line 79 of file pm.h.

#define AR_DATA   (2<<3)
 

Definition at line 78 of file pm.h.

#define AR_INTERRUPT   (0xe)
 

Definition at line 83 of file pm.h.

Referenced by idt_init().

#define AR_PRESENT   (1<<7)
 

Definition at line 77 of file pm.h.

#define AR_READABLE   (1<<1)
 

Definition at line 81 of file pm.h.

#define AR_TRAP   (0xf)
 

Definition at line 84 of file pm.h.

#define AR_TSS   (0x9)
 

Definition at line 82 of file pm.h.

Referenced by io_perm_bitmap_install(), and pm_init().

#define AR_WRITABLE   (1<<1)
 

Definition at line 80 of file pm.h.

#define atomic_predec val   )     (atomic_postdec(val)-1)
 

Definition at line 84 of file atomic.h.

#define atomic_preinc val   )     (atomic_postinc(val)+1)
 

Definition at line 83 of file atomic.h.

Referenced by check_call_limit(), ipc_irq_send_msg(), and ipc_irq_send_notif().

#define BOOT_OFFSET   0x108000
 

Definition at line 38 of file boot.h.

#define BOOT_STACK_SIZE   0x400
 

Definition at line 40 of file boot.h.

#define DPL_KERNEL   (PL_KERNEL<<5)
 

Definition at line 86 of file pm.h.

#define DPL_USER   (PL_USER<<5)
 

Definition at line 87 of file pm.h.

#define EFER_MSR_NUM   0xc0000080
 

Definition at line 41 of file cpu.h.

#define ELF_CLASS   ELFCLASS64
 

Definition at line 40 of file elf.h.

Referenced by elf_load().

#define ELF_DATA_ENCODING   ELFDATA2LSB
 

Definition at line 39 of file elf.h.

Referenced by elf_load().

#define ELF_MACHINE   EM_X86_64
 

Definition at line 38 of file elf.h.

Referenced by elf_load().

#define FADDR fptr   )     ((__address) (fptr))
 

Definition at line 40 of file faddr.h.

Referenced by main_ap(), scheduler(), and thread_create().

#define GDT_ITEMS   8
 

Definition at line 45 of file pm.h.

#define gdtselector des   )     ((des)<<3)
 

Definition at line 71 of file pm.h.

Referenced by idt_init(), io_perm_bitmap_install(), pm_init(), syscall_setup_cpu(), and userspace().

#define GEN_READ_REG reg   ) 
 

Value:

static inline __native read_ ##reg (void) \
    { \
        __native res; \
        __asm__ volatile ("movq %%" #reg ", %0" : "=r" (res) ); \
        return res; \
    }

Definition at line 246 of file asm.h.

#define GEN_WRITE_REG reg   ) 
 

Value:

static inline void write_ ##reg (__native regn) \
    { \
        __asm__ volatile ("movq %0, %%" #reg : : "r" (regn)); \
    }

Definition at line 253 of file asm.h.

#define IDT_ITEMS   64
 

Definition at line 44 of file pm.h.

Referenced by idt_init().

#define idtselector des   )     ((des)<<4)
 

Definition at line 72 of file pm.h.

#define INTEL_CPUID_EBX   0x756e6547
 

Definition at line 53 of file cpu.c.

Referenced by cpu_identify().

#define INTEL_CPUID_ECX   0x6c65746e
 

Definition at line 54 of file cpu.c.

Referenced by cpu_identify().

#define INTEL_CPUID_EDX   0x49656e69
 

Definition at line 55 of file cpu.c.

Referenced by cpu_identify().

#define INTEL_CPUID_STANDARD   0x1
 

Definition at line 41 of file cpuid.h.

Referenced by arch_pre_mm_init().

#define INTEL_FXSAVE   24
 

Definition at line 43 of file cpuid.h.

Referenced by arch_pre_mm_init().

#define INTEL_SSE2   26
 

Definition at line 42 of file cpuid.h.

Referenced by arch_pre_mm_init().

#define IO_PORTS   (64*1024)
 

Definition at line 92 of file pm.h.

Referenced by ddi_iospace_enable_arch().

#define KDATA_DES   2
 

Definition at line 51 of file pm.h.

Referenced by syscall_setup_cpu().

#define KTEXT32_DES   5
 

Definition at line 54 of file pm.h.

#define KTEXT_DES   1
 

Definition at line 50 of file pm.h.

Referenced by idt_init(), and syscall_setup_cpu().

#define MULTIBOOT_HEADER_FLAGS   0x00010003
 

Definition at line 43 of file boot.h.

#define MULTIBOOT_HEADER_MAGIC   0x1BADB002
 

Definition at line 42 of file boot.h.

#define MULTIBOOT_LOADER_MAGIC   0x2BADB002
 

Definition at line 45 of file boot.h.

#define NULL   0
 

Definition at line 38 of file types.h.

Referenced by _btree_insert(), _btree_remove(), _rwlock_read_lock_timeout(), _slab_reclaim(), _waitq_wakeup_unsafe(), acpi_init(), anon_share(), as_area_create(), breakpoint_del(), btree_init(), btree_insert(), btree_leaf_node_left_neighbour(), btree_leaf_node_right_neighbour(), btree_search(), buddy_system_alloc(), check_area_conflicts(), clock_counter_init(), cmdtab_compl(), code_from_uspace(), cpu_arch_init(), debugger_init(), elf_share(), fb_init(), find_best_thread(), find_free_zone_lock(), find_zone_and_lock(), frame_alloc_generic(), frame_free(), frame_reference_add(), futex_find(), get_call(), get_full_current_mag(), get_mag_from_cache(), get_symbol_addr(), i8042_init(), ipc_init(), ipc_irq_cleanup(), ipc_irq_make_table(), ipc_irq_register(), ipc_irq_unregister(), ipc_phone_init(), ipc_wait_for_call(), kcpulb(), kinit(), klog_init(), ktaskclnp(), ktaskgc(), let_others_in(), link_initialize(), magazine_destroy(), magazine_obj_get(), main_bsp_separated_stack(), make_empty_current_mag(), node_initialize(), parse_argument(), parse_cmdline(), print_string(), printf_putstr(), pt_mapping_find(), rotate_from_left(), rotate_from_right(), scheduler(), scheduler_separated_stack(), slab_alloc(), slab_cache_init(), slab_free(), slab_obj_create(), slab_space_alloc(), sys_as_area_create(), sys_ipc_answer(), sys_ipc_answer_fast(), sys_sysinfo_valid(), sys_sysinfo_value(), sysinfo_create_path(), sysinfo_dump(), sysinfo_find_item(), sysinfo_get_val(), sysinfo_set_item_function(), sysinfo_set_item_undefined(), sysinfo_set_item_val(), task_create(), task_create_arch(), task_destroy(), task_init(), task_kill(), task_run_program(), the_initialize(), thr_constructor(), thread_create(), thread_destroy(), thread_exists(), thread_init(), timeout_register(), timeout_reinitialize(), uinit(), vprintf(), waitq_interrupt_sleep(), waitq_timeouted_sleep(), zone_buddy_find_block(), zone_buddy_find_buddy(), zone_print_list(), and zone_print_one().

#define NULL_DES   0
 

Definition at line 48 of file pm.h.

#define PL_KERNEL   0
 

Definition at line 74 of file pm.h.

Referenced by pm_init(), and syscall_setup_cpu().

#define PL_USER   3
 

Definition at line 75 of file pm.h.

Referenced by syscall_setup_cpu(), and userspace().

#define RFLAGS_IF   (1 << 9)
 

Definition at line 38 of file cpu.h.

#define RFLAGS_RF   (1 << 16)
 

Definition at line 39 of file cpu.h.

Referenced by debug_exception().

#define SP_DELTA   16
 

Definition at line 47 of file context.h.

Referenced by before_thread_runs_arch().

#define TSS_BASIC_SIZE   104
 

Definition at line 89 of file pm.h.

Referenced by io_perm_bitmap_install(), and pm_init().

#define TSS_DES   6
 

Definition at line 56 of file pm.h.

Referenced by io_perm_bitmap_install(), and pm_init().

#define TSS_IOMAP_SIZE   (16*1024+1)
 

Definition at line 90 of file pm.h.

Referenced by io_perm_bitmap_install().

#define UDATA_DES   3
 

Definition at line 52 of file pm.h.

Referenced by userspace().

#define UTEXT_DES   4
 

Definition at line 53 of file pm.h.

Referenced by userspace().


Typedef Documentation

typedef __u64 __address
 

Definition at line 50 of file types.h.

typedef __u64 __native
 

Definition at line 56 of file types.h.

typedef signed short __s16
 

Definition at line 41 of file types.h.

typedef signed int __s32
 

Definition at line 42 of file types.h.

typedef signed long long __s64
 

Definition at line 43 of file types.h.

typedef signed char __s8
 

Definition at line 40 of file types.h.

typedef __s64 __snative
 

Definition at line 57 of file types.h.

typedef unsigned short __u16
 

Definition at line 46 of file types.h.

typedef unsigned int __u32
 

Definition at line 47 of file types.h.

typedef unsigned long long __u64
 

Definition at line 48 of file types.h.

typedef unsigned char __u8
 

Definition at line 45 of file types.h.

typedef struct descriptor descriptor_t
 

Definition at line 108 of file pm.h.

typedef struct idescriptor idescriptor_t
 

Definition at line 140 of file pm.h.

typedef __u64 ipl_t
 

Definition at line 54 of file types.h.

typedef __u64 pfn_t
 

Definition at line 51 of file types.h.

typedef struct page_specifier pte_t
 

Definition at line 59 of file types.h.

typedef struct ptr_16_32 ptr_16_32_t
 

Definition at line 152 of file pm.h.

typedef struct ptr_16_64 ptr_16_64_t
 

Definition at line 146 of file pm.h.

typedef struct tss_descriptor tss_descriptor_t
 

Definition at line 126 of file pm.h.

typedef struct tss tss_t
 

Definition at line 172 of file pm.h.


Enumeration Type Documentation

enum vendor
 

Enumerator:
VendorUnknown 
VendorAMD 
VendorIntel 

Definition at line 58 of file cpu.c.


Function Documentation

void arch_grab_console void   ) 
 

Acquire console back for kernel

Definition at line 199 of file amd64.c.

References i8042_grab().

Referenced by sys_debug_enable_console().

Here is the call graph for this function:

void arch_post_mm_init void   ) 
 

Definition at line 140 of file amd64.c.

References config, config_t::cpu_active, debugger_init(), syscall_setup_cpu(), vesa_init(), vesa_present(), and zone_merge_all().

Referenced by main_ap(), and main_bsp_separated_stack().

Here is the call graph for this function:

void arch_post_smp_init void   ) 
 

Definition at line 170 of file amd64.c.

References i8042_init().

Here is the call graph for this function:

void arch_pre_mm_init void   ) 
 

Definition at line 98 of file amd64.c.

References AMD_CPUID_EXTENDED, AMD_EXT_NOEXECUTE, AMD_NXE_FLAG, clean_AM_flag(), clean_IOPL_NT_flags(), config, config_t::cpu_active, cpu_setup_fpu(), cpuid(), cpu_info::cpuid_edx, exc_register(), INTEL_CPUID_STANDARD, INTEL_FXSAVE, INTEL_SSE2, panic, pm_init(), set_efer_flag(), tlb_shootdown_ipi(), and VECTOR_TLB_SHOOTDOWN_IPI.

Referenced by main_ap(), and main_bsp_separated_stack().

Here is the call graph for this function:

void arch_pre_smp_init void   ) 
 

Definition at line 159 of file amd64.c.

References acpi_init(), config, config_t::cpu_active, and memory_print_map().

Referenced by main_bsp_separated_stack().

Here is the call graph for this function:

void arch_release_console void   ) 
 

Return console to userspace

Definition at line 206 of file amd64.c.

References i8042_release().

Referenced by cmd_continue().

Here is the call graph for this function:

void asm_delay_loop __u32  t  ) 
 

Referenced by delay().

void asm_fake_loop __u32  t  ) 
 

static void atomic_dec atomic_t val  )  [static]
 

Definition at line 51 of file atomic.h.

References atomic::count.

Referenced by _slab_free(), check_call_limit(), get_mag_from_cache(), ipc_wait_for_call(), kcpulb(), magazine_destroy(), magazine_obj_get(), slab_space_free(), and sys_ipc_wait_for_call().

static void atomic_inc atomic_t val  )  [static]
 

Definition at line 43 of file atomic.h.

References atomic::count.

Referenced by _ipc_call(), ipc_backsend_err(), magazine_obj_put(), put_mag_to_cache(), slab_alloc(), slab_space_alloc(), and thread_ready().

static void atomic_lock_arch atomic_t val  )  [static]
 

amd64 specific fast spinlock

Definition at line 100 of file atomic.h.

References atomic::count, and preemption_disable().

Here is the call graph for this function:

static long atomic_postdec atomic_t val  )  [static]
 

Definition at line 71 of file atomic.h.

References atomic::count.

static long atomic_postinc atomic_t val  )  [static]
 

Definition at line 59 of file atomic.h.

References atomic::count.

void calibrate_delay_loop void   ) 
 

Definition at line 175 of file amd64.c.

Referenced by main_ap(), and main_bsp_separated_stack().

static void clean_AM_flag void   )  [static]
 

Disable alignment check

Clean AM(18) flag in CR0 register

Definition at line 85 of file amd64.c.

Referenced by arch_pre_mm_init().

static void clean_IOPL_NT_flags void   )  [static]
 

Disable I/O on non-privileged levels

Clean IOPL(12,13) and NT(14) flags in EFLAGS register

Definition at line 66 of file amd64.c.

Referenced by arch_pre_mm_init().

void cpu_arch_init void   ) 
 

Definition at line 124 of file cpu.c.

References CPU, NULL, and tss_p.

static void cpu_halt void   )  [static]
 

Definition at line 61 of file asm.h.

Referenced by _getc(), and halt().

void cpu_identify void   ) 
 

Definition at line 131 of file cpu.c.

References AMD_CPUID_EBX, AMD_CPUID_ECX, AMD_CPUID_EDX, CPU, cpuid(), has_cpuid(), info, INTEL_CPUID_EBX, INTEL_CPUID_ECX, INTEL_CPUID_EDX, VendorAMD, VendorIntel, and VendorUnknown.

Here is the call graph for this function:

void cpu_print_report cpu_t m  ) 
 

Definition at line 160 of file cpu.c.

References cpu::arch, cpu_arch::family, cpu::frequency_mhz, cpu::id, cpu_arch::model, printf(), cpu_arch::stepping, cpu_arch::vendor, and vendor_str.

Referenced by cpu_list().

Here is the call graph for this function:

void cpu_setup_fpu void   ) 
 

Setup flags on processor so that we can use the FPU

cr0.osfxsr = 1 -> we do support fxstor/fxrestor cr0.em = 0 -> we do not emulate coprocessor cr0.mp = 1 -> we do want lazy context switch

Definition at line 77 of file cpu.c.

Referenced by arch_pre_mm_init().

static void cpu_sleep void   )  [static]
 

Definition at line 60 of file asm.h.

Referenced by find_best_thread().

void cpuid __u32  cmd,
cpu_info_t info
 

Referenced by arch_pre_mm_init(), and cpu_identify().

static void enable_l_apic_in_msr  )  [static]
 

Enable local APIC

Enable local APIC in MSR.

Definition at line 176 of file asm.h.

void fpu_context_restore fpu_context_t fctx  ) 
 

Restore FPU (mmx,sse) context using fxrstor instruction

Definition at line 50 of file fpu_context.c.

Referenced by before_thread_runs().

void fpu_context_save fpu_context_t fctx  ) 
 

Save FPU (mmx, sse) context using fxsave instruction

Definition at line 41 of file fpu_context.c.

Referenced by scheduler().

void fpu_disable void   ) 
 

Set the TS flag to 1.

If a thread accesses coprocessor, exception is run, which does a lazy fpu context switch.

Definition at line 100 of file cpu.c.

Referenced by before_thread_runs().

void fpu_enable void   ) 
 

Definition at line 112 of file cpu.c.

Referenced by before_thread_runs().

void fpu_init void   ) 
 

Definition at line 58 of file fpu_context.c.

Referenced by before_thread_runs().

void gdt_tss_setbase descriptor_t d,
__address  base
 

Definition at line 132 of file pm.c.

References tss_descriptor::base_0_15, tss_descriptor::base_16_23, tss_descriptor::base_24_31, and tss_descriptor::base_32_63.

Referenced by pm_init().

void gdt_tss_setlimit descriptor_t d,
__u32  limit
 

Definition at line 142 of file pm.c.

References tss_descriptor::limit_0_15, and tss_descriptor::limit_16_19.

Referenced by io_perm_bitmap_install(), and pm_init().

static void gdtr_load struct ptr_16_64 gdtr_reg  )  [static]
 

Load GDTR register from memory.

Parameters:
gdtr_reg Address of memory from where to load GDTR.

Definition at line 214 of file asm.h.

Referenced by io_perm_bitmap_install(), and pm_init().

static void gdtr_store struct ptr_16_64 gdtr_reg  )  [static]
 

Store GDTR register to memory.

Parameters:
gdtr_reg Address of memory to where to load GDTR.

Definition at line 223 of file asm.h.

Referenced by io_perm_bitmap_install().

GEN_READ_REG dr7   ) 
 

GEN_READ_REG dr6   ) 
 

GEN_READ_REG dr3   ) 
 

GEN_READ_REG dr2   ) 
 

GEN_READ_REG dr1   ) 
 

GEN_READ_REG dr0   ) 
 

GEN_READ_REG cr3   ) 
 

GEN_READ_REG cr2   ) 
 

GEN_READ_REG cr0   ) 
 

GEN_WRITE_REG dr7   ) 
 

GEN_WRITE_REG dr6   ) 
 

GEN_WRITE_REG dr3   ) 
 

GEN_WRITE_REG dr2   ) 
 

GEN_WRITE_REG dr1   ) 
 

GEN_WRITE_REG dr0   ) 
 

GEN_WRITE_REG cr3   ) 
 

static __address* get_ip  )  [static]
 

Definition at line 190 of file asm.h.

static __address get_stack_base void   )  [static]
 

Return base address of current stack.

Return the base address of the current stack. The stack is assumed to be STACK_SIZE bytes long. The stack must start on page boundary.

Definition at line 51 of file asm.h.

References STACK_SIZE.

int has_cpuid void   ) 
 

Referenced by cpu_identify().

void idt_init void   ) 
 

Definition at line 168 of file pm.c.

References AR_INTERRUPT, exc_register(), gdtselector, idt, IDT_ITEMS, idt_setoffset(), interrupt_handler_size, interrupt_handlers(), KTEXT_DES, null_interrupt(), idescriptor::present, idescriptor::selector, idescriptor::type, and idescriptor::unused.

Referenced by pm_init().

Here is the call graph for this function:

void idt_setoffset idescriptor_t d,
__address  offset
 

Definition at line 150 of file pm.c.

References idescriptor::offset_0_15, idescriptor::offset_16_31, and idescriptor::offset_32_63.

Referenced by idt_init().

static void idtr_load struct ptr_16_64 idtr_reg  )  [static]
 

Load IDTR register from memory.

Parameters:
idtr_reg Address of memory from where to load IDTR.

Definition at line 232 of file asm.h.

Referenced by pm_init().

static __u8 inb __u16  port  )  [static]
 

Byte from port

Get byte from port

Parameters:
port Port to read from
Returns:
Value read

Definition at line 71 of file asm.h.

Referenced by code_execute().

void interrupt_handlers void   ) 
 

Referenced by idt_init().

static ipl_t interrupts_disable void   )  [static]
 

Disable interrupts.

Disable interrupts and return previous value of EFLAGS.

Returns:
Old interrupt priority level.

Definition at line 110 of file asm.h.

static ipl_t interrupts_enable void   )  [static]
 

Enable interrupts.

Enable interrupts and return previous value of EFLAGS.

Returns:
Old interrupt priority level.

Definition at line 92 of file asm.h.

static ipl_t interrupts_read void   )  [static]
 

Return interrupt priority level.

Return EFLAFS.

Returns:
Current interrupt priority level.

Definition at line 141 of file asm.h.

static void interrupts_restore ipl_t  ipl  )  [static]
 

Restore interrupt priority level.

Restore EFLAGS.

Parameters:
ipl Saved interrupt priority level.

Definition at line 127 of file asm.h.

static void invlpg __address  addr  )  [static]
 

Invalidate TLB Entry.

Parameters:
addr Address on a page whose TLB entry is to be invalidated.

Definition at line 205 of file asm.h.

static int memcmp const void *  src,
const void *  dst,
size_t  cnt
[static]
 

Compare memory regions for equality

Compare a given number of bytes (3rd argument) at memory locations defined by 1st and 2nd argument for equality. If bytes are equal function returns 0.

Parameters:
src Region 1
dst Region 2
cnt Number of bytes
Returns:
Zero if bytes are equal, non-zero otherwise

Definition at line 80 of file memstr.h.

static void* memcpy void *  dst,
const void *  src,
size_t  cnt
[static]
 

Copy memory

Copy a given number of bytes (3rd argument) from the memory location defined by 2nd argument to the memory location defined by 1st argument. The memory areas cannot overlap.

Parameters:
dst Destination
src Source
cnt Number of bytes
Returns:
Destination

Definition at line 50 of file memstr.h.

Referenced by _bubblesort(), _qsort(), clear_screen(), ptl0_create(), scroll_screen(), sys_ipc_answer(), sys_ipc_answer_fast(), thread_create(), and vsnprintf_write().

static void memsetb __address  dst,
size_t  cnt,
__u8  x
[static]
 

Fill memory with bytes Fill a given number of bytes (2nd argument) at memory defined by 1st argument with the word value defined by 3rd argument.

Parameters:
dst Destination
cnt Number of bytes
x Value to fill

Definition at line 129 of file memstr.h.

Referenced by _ipc_call_init(), _slab_cache_create(), anon_page_fault(), as_area_create(), cpu_init(), hash_table_create(), make_magcache(), pt_mapping_insert(), pt_mapping_remove(), ptl0_create(), thread_create(), and tss_initialize().

static void memsetw __address  dst,
size_t  cnt,
__u16  x
[static]
 

Fill memory with words Fill a given number of words (2nd argument) at memory defined by 1st argument with the word value defined by 3rd argument.

Parameters:
dst Destination
cnt Number of words
x Value to fill

Definition at line 107 of file memstr.h.

static void outb __u16  port,
__u8  val
[static]
 

Byte to port

Output byte to port

Parameters:
port Port to write to
val Value to write

Definition at line 80 of file asm.h.

Referenced by code_execute().

void pm_init void   ) 
 

Initialize segmentation - code/data/idt tables

Definition at line 195 of file pm.c.

References AR_TSS, AS_KERNEL, ptr_16_64::base, config, config_t::cpu_active, FRAME_ATOMIC, gdt_tss_setbase(), gdt_tss_setlimit(), gdtr, gdtr_load(), gdtselector, idt_init(), idtr, idtr_load(), malloc(), panic, PL_KERNEL, tr_load(), tss, TSS_BASIC_SIZE, TSS_DES, tss_initialize(), and tss_p.

Referenced by arch_pre_mm_init().

Here is the call graph for this function:

__u64 rdtsc void   ) 
 

__u64 read_efer_flag void   ) 
 

static __native read_msr __u32  msr  )  [static]
 

Definition at line 161 of file asm.h.

void set_efer_flag int  flag  ) 
 

Referenced by arch_pre_mm_init(), and syscall_setup_cpu().

static void swapgs void   )  [static]
 

Swap Hidden part of GS register with visible one

Definition at line 83 of file asm.h.

Referenced by before_thread_runs_arch().

__native sys_tls_set __native  addr  ) 
 

Set thread-local-storage pointer

TLS pointer is set in FS register. Unfortunately the 64-bit part can be set only in CPL0 mode.

The specs say, that on fs:0 there is stored contents of fs register, we need not to go to CPL0 to read it.

Definition at line 189 of file amd64.c.

References AMD_MSR_FS, THREAD, and write_msr().

Here is the call graph for this function:

void syscall_entry void   ) 
 

Referenced by syscall_setup_cpu().

void syscall_setup_cpu void   ) 
 

Enable & setup support for SYSCALL/SYSRET

Definition at line 48 of file syscall.c.

References AMD_MSR_LSTAR, AMD_MSR_SFMASK, AMD_MSR_STAR, AMD_SCE_FLAG, gdtselector, KDATA_DES, KTEXT_DES, PL_KERNEL, PL_USER, set_efer_flag(), syscall_entry(), and write_msr().

Referenced by arch_post_mm_init().

Here is the call graph for this function:

static __u64 test_and_set atomic_t val  )  [static]
 

Definition at line 86 of file atomic.h.

References atomic::count.

Referenced by spinlock_trylock().

static void tr_load __u16  sel  )  [static]
 

Load TR from descriptor table.

Parameters:
sel Selector specifying descriptor of TSS segment.

Definition at line 241 of file asm.h.

Referenced by io_perm_bitmap_install(), and pm_init().

void tss_initialize tss_t t  ) 
 

Definition at line 160 of file pm.c.

References memsetb().

Referenced by pm_init().

Here is the call graph for this function:

void userspace uspace_arg_t kernel_uarg  ) 
 

Enter userspace

Change CPU protection level to 3, enter userspace.

Definition at line 48 of file userspace.c.

References gdtselector, interrupts_disable(), PL_USER, THREAD_STACK_SIZE, UDATA_DES, uspace_arg::uspace_entry, uspace_arg::uspace_stack, uspace_arg::uspace_uarg, and UTEXT_DES.

Referenced by uinit().

Here is the call graph for this function:

void vesa_init void   ) 
 

Referenced by arch_post_mm_init().

int vesa_present void   ) 
 

Referenced by arch_post_mm_init().

static void write_msr __u32  msr,
__u64  value
[static]
 

Write to MSR

Definition at line 152 of file asm.h.

Referenced by before_thread_runs_arch(), sys_tls_set(), and syscall_setup_cpu().


Variable Documentation

ptr_16_32_t bootstrap_gdtr
 

descriptor_t gdt[GDT_ITEMS]
 

Definition at line 56 of file pm.c.

descriptor_t gdt[]
 

Definition at line 56 of file pm.c.

ptr_16_64_t gdtr = {.limit = sizeof(gdt), .base= (__u64) gdt }
 

Definition at line 126 of file pm.c.

Referenced by pm_init().

ptr_16_64_t gdtr
 

Definition at line 126 of file pm.c.

Referenced by pm_init().

idescriptor_t idt[IDT_ITEMS]
 

Definition at line 124 of file pm.c.

Referenced by idt_init().

idescriptor_t idt[]
 

Definition at line 124 of file pm.c.

Referenced by idt_init().

ptr_16_64_t idtr = {.limit = sizeof(idt), .base= (__u64) idt }
 

Definition at line 127 of file pm.c.

Referenced by pm_init().

size_t interrupt_handler_size
 

Referenced by idt_init().

struct tss packed
 

struct ptr_16_32 packed
 

struct ptr_16_64 packed
 

struct idescriptor packed
 

struct tss_descriptor packed
 

struct descriptor packed
 

struct cpu_info packed
 

struct context packed
 

ptr_16_32_t protected_ap_gdtr
 

tss_t tss [static]
 

Definition at line 129 of file pm.c.

Referenced by pm_init().

tss_t* tss_p = NULL
 

Definition at line 130 of file pm.c.

Referenced by cpu_arch_init(), and pm_init().

tss_t* tss_p
 

Definition at line 130 of file pm.c.

Referenced by cpu_arch_init(), and pm_init().

char* vendor_str[] [static]
 

Initial value:

 {
        "Unknown Vendor",
        "AuthenticAMD",
        "GenuineIntel"
}

Definition at line 64 of file cpu.c.

Referenced by cpu_print_report().


Generated on Sun Jun 18 16:38:18 2006 for HelenOS Kernel (amd64) by  doxygen 1.4.6