1
0
Fork 0
mirror of https://github.com/tailix/libkernaux.git synced 2024-12-04 11:25:18 -05:00

Add funcs to work with i386 cr* registers

This commit is contained in:
Alex Kotov 2020-11-27 16:00:34 +05:00
parent e09447168d
commit 13a2306622
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08
5 changed files with 39 additions and 2 deletions

4
.gitignore vendored
View file

@ -1,5 +1,7 @@
*.a
*.o
.deps/
.dirstamp
/Makefile
/Makefile.in
@ -17,5 +19,3 @@
/include/Makefile.in
/install-sh
/missing
/src/.deps/
/src/.dirstamp

View file

@ -5,4 +5,5 @@ AM_CFLAGS = -I$(top_srcdir)/include
lib_LIBRARIES = libkernaux.a
libkernaux_a_SOURCES = \
src/arch/i386.S \
src/pfa.c

View file

@ -17,6 +17,7 @@ AC_CONFIG_FILES([
AC_LANG([C])
AM_PROG_AR
AM_PROG_AS
AC_PROG_CC
AC_PROG_RANLIB

View file

@ -5,6 +5,13 @@
extern "C" {
#endif
unsigned long kernaux_arch_i386_read_cr0();
unsigned long kernaux_arch_i386_read_cr4();
void kernaux_arch_i386_write_cr0(volatile unsigned long value);
void kernaux_arch_i386_write_cr3(volatile unsigned long value);
void kernaux_arch_i386_write_cr4(volatile unsigned long value);
#ifdef __cplusplus
}
#endif

28
src/arch/i386.S Normal file
View file

@ -0,0 +1,28 @@
.global kernaux_arch_i386_read_cr0
.global kernaux_arch_i386_read_cr4
.global kernaux_arch_i386_write_cr0
.global kernaux_arch_i386_write_cr3
.global kernaux_arch_i386_write_cr4
kernaux_arch_i386_read_cr0:
mov %cr0, %eax
ret
kernaux_arch_i386_read_cr4:
mov %cr4, %eax
ret
kernaux_arch_i386_write_cr0:
mov 4(%esp), %eax
mov %eax, %cr0
ret
kernaux_arch_i386_write_cr3:
mov 4(%esp), %eax
mov %eax, %cr3
ret
kernaux_arch_i386_write_cr4:
mov 4(%esp), %eax
mov %eax, %cr4
ret