Turnstone Operating System
Loading...
Searching...
No Matches
cpu.64.c File Reference

64 bit cpu operations More...

#include <cpu.h>
#include <cpu/crx.h>

Functions

 MODULE ("turnstone.kernel.cpu")
 
uint64_t cpu_read_msr (uint32_t msr_address)
 read msr and return More...
 
int8_t cpu_write_msr (uint32_t msr_address, uint64_t value)
 writes msr More...
 
uint64_t cpu_read_cr2 (void)
 read cr2 and return More...
 
uint64_t cpu_read_cr3 (void)
 read cr3 and return More...
 
cpu_reg_cr4_t cpu_read_cr4 (void)
 reads cr4 register More...
 
void cpu_write_cr4 (cpu_reg_cr4_t cr4)
 writes cr4 register More...
 
cpu_reg_cr0_t cpu_read_cr0 (void)
 reads cr0 register More...
 
void cpu_write_cr0 (cpu_reg_cr0_t cr0)
 writes cr0 register More...
 
void cpu_toggle_cr0_wp (void)
 toggles write protect bit cr0, when setted kernel can not modify readonly pages
 
void cpu_cr0_disable_wp (void)
 disables write protect bit cr0, when setted kernel can not modify readonly pages
 
void cpu_cr0_enable_wp (void)
 enables write protect bit cr0, when setted kernel can not modify readonly pages
 
void cpu_enable_sse (void)
 enables sse support, modifies cr4 register
 
void cpu_clear_segments (void)
 clears segments More...
 
uint64_t cpu_read_fs_base (void)
 
uint64_t cpu_read_gs_base (void)
 

Detailed Description

64 bit cpu operations

This work is licensed under TURNSTONE OS Public License. Please read and understand latest version of Licence.

Function Documentation

◆ cpu_clear_segments()

void cpu_clear_segments ( void  )

clears segments

sets segment registers to zero

◆ cpu_read_cr0()

cpu_reg_cr0_t cpu_read_cr0 ( void  )

reads cr0 register

Returns
cr0 value

◆ cpu_read_cr2()

uint64_t cpu_read_cr2 ( void  )

read cr2 and return

Returns
cr2 value

returns cr2 value for page faults

◆ cpu_read_cr3()

uint64_t cpu_read_cr3 ( void  )

read cr3 and return

Returns
cr3 value

returns cr3 value for page tables

◆ cpu_read_cr4()

cpu_reg_cr4_t cpu_read_cr4 ( void  )

reads cr4 register

Returns
cr4 value

◆ cpu_read_msr()

uint64_t cpu_read_msr ( uint32_t  msr_address)

read msr and return

Parameters
[in]msr_addressmodel Specific register address
Returns
msr value

returns edx:eax as uint64_t

◆ cpu_write_cr0()

void cpu_write_cr0 ( cpu_reg_cr0_t  cr0)

writes cr0 register

Parameters
[in]cr0cr0 value

◆ cpu_write_cr4()

void cpu_write_cr4 ( cpu_reg_cr4_t  cr4)

writes cr4 register

Parameters
[in]cr4cr4 value

◆ cpu_write_msr()

int8_t cpu_write_msr ( uint32_t  msr_address,
uint64_t  value 
)

writes msr

Parameters
[in]msr_addressmodel Specific register address
[in]valuevalue to write
Returns
0 on sucess

parse value into edx:eax