mirror of
https://github.com/tailix/libkernaux.git
synced 2025-03-03 16:04:29 -05:00
Rename "i386" to "x86"
This commit is contained in:
parent
e3b4a32272
commit
d3aca7d855
8 changed files with 127 additions and 127 deletions
|
@ -22,8 +22,8 @@ libkernaux_a_SOURCES = \
|
|||
src/pfa.c \
|
||||
src/stdlib.c
|
||||
|
||||
if ARCH_I386
|
||||
libkernaux_a_SOURCES += src/arch/i386.S
|
||||
if ARCH_X86
|
||||
libkernaux_a_SOURCES += src/arch/x86.S
|
||||
endif
|
||||
|
||||
tests_multiboot2_print1_SOURCES = \
|
||||
|
|
26
README.md
26
README.md
|
@ -44,10 +44,10 @@ Configure with cross-compiler in `$PATH` to make without it in `$PATH`:
|
|||
|
||||
```
|
||||
./configure \
|
||||
--host=i386-elf \
|
||||
AR="$(which i386-elf-ar)" \
|
||||
CC="$(which i386-elf-gcc)" \
|
||||
RANLIB="$(which i386-elf-ranlib)" \
|
||||
--host=x86-elf \
|
||||
AR="$(which x86-elf-ar)" \
|
||||
CC="$(which x86-elf-gcc)" \
|
||||
RANLIB="$(which x86-elf-ranlib)" \
|
||||
CFLAGS='-ffreestanding -nostdinc -nostdlib -fno-builtin -fno-stack-protector'
|
||||
```
|
||||
|
||||
|
@ -61,39 +61,39 @@ just `make && sudo make install`. Instead use the following commands:
|
|||
* `sudo make install-exec`
|
||||
* `sudo make install-data`
|
||||
|
||||
Check if compilation targets i386: `objdump -d src/arch/i386.o`. It should
|
||||
Check if compilation targets x86: `objdump -d src/arch/x86.o`. It should
|
||||
output something like this:
|
||||
|
||||
```
|
||||
src/arch/i386.o: file format elf32-i386
|
||||
src/arch/x86.o: file format elf32-i386
|
||||
|
||||
|
||||
Disassembly of section .text:
|
||||
|
||||
00000000 <kernaux_arch_i386_hang>:
|
||||
00000000 <kernaux_arch_x86_hang>:
|
||||
0: fa cli
|
||||
1: f4 hlt
|
||||
2: eb fc jmp 0 <kernaux_arch_i386_hang>
|
||||
2: eb fc jmp 0 <kernaux_arch_x86_hang>
|
||||
|
||||
00000004 <kernaux_arch_i386_read_cr0>:
|
||||
00000004 <kernaux_arch_x86_read_cr0>:
|
||||
4: 0f 20 c0 mov %cr0,%eax
|
||||
7: c3 ret
|
||||
|
||||
00000008 <kernaux_arch_i386_read_cr4>:
|
||||
00000008 <kernaux_arch_x86_read_cr4>:
|
||||
8: 0f 20 e0 mov %cr4,%eax
|
||||
b: c3 ret
|
||||
|
||||
0000000c <kernaux_arch_i386_write_cr0>:
|
||||
0000000c <kernaux_arch_x86_write_cr0>:
|
||||
c: 8b 44 24 04 mov 0x4(%esp),%eax
|
||||
10: 0f 22 c0 mov %eax,%cr0
|
||||
13: c3 ret
|
||||
|
||||
00000014 <kernaux_arch_i386_write_cr3>:
|
||||
00000014 <kernaux_arch_x86_write_cr3>:
|
||||
14: 8b 44 24 04 mov 0x4(%esp),%eax
|
||||
18: 0f 22 d8 mov %eax,%cr3
|
||||
1b: c3 ret
|
||||
|
||||
0000001c <kernaux_arch_i386_write_cr4>:
|
||||
0000001c <kernaux_arch_x86_write_cr4>:
|
||||
1c: 8b 44 24 04 mov 0x4(%esp),%eax
|
||||
20: 0f 22 e0 mov %eax,%cr4
|
||||
23: c3 ret
|
||||
|
|
|
@ -9,7 +9,7 @@ AC_CONFIG_SRCDIR([src/pfa.c])
|
|||
|
||||
AC_CANONICAL_HOST
|
||||
|
||||
AM_CONDITIONAL(ARCH_I386, test "${host_cpu}" = "i386")
|
||||
AM_CONDITIONAL(ARCH_X86, test "${host_cpu}" = "x86")
|
||||
|
||||
AM_INIT_AUTOMAKE([1.9 subdir-objects -Wall -Werror])
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
nobase_include_HEADERS = \
|
||||
kernaux/arch/i386.h \
|
||||
kernaux/arch/x86.h \
|
||||
kernaux/multiboot2.h \
|
||||
kernaux/pfa.h \
|
||||
kernaux/stdlib.h
|
||||
|
|
|
@ -1,76 +0,0 @@
|
|||
#ifndef KERNAUX_INCLUDED_ARCH_I386
|
||||
#define KERNAUX_INCLUDED_ARCH_I386 1
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
inline static unsigned char kernaux_arch_i386_inportb(unsigned short port);
|
||||
inline static unsigned short kernaux_arch_i386_inportw(unsigned short port);
|
||||
inline static unsigned int kernaux_arch_i386_inportd(unsigned short port);
|
||||
|
||||
inline static void
|
||||
kernaux_arch_i386_outportb(unsigned short port, unsigned char value);
|
||||
|
||||
inline static void
|
||||
kernaux_arch_i386_outportw(unsigned short port, unsigned short value);
|
||||
|
||||
inline static void
|
||||
kernaux_arch_i386_outportd(unsigned short port, unsigned int value);
|
||||
|
||||
void kernaux_arch_i386_hang() __attribute__((noreturn));
|
||||
|
||||
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);
|
||||
|
||||
unsigned char kernaux_arch_i386_inportb(const unsigned short port)
|
||||
{
|
||||
register unsigned char result;
|
||||
asm volatile("inb %1, %0" : "=a" (result) : "dN" (port));
|
||||
return result;
|
||||
}
|
||||
|
||||
unsigned short kernaux_arch_i386_inportw(const unsigned short port)
|
||||
{
|
||||
register unsigned short result;
|
||||
asm volatile("inw %1, %0" : "=a" (result) : "dN" (port));
|
||||
return result;
|
||||
}
|
||||
|
||||
unsigned int kernaux_arch_i386_inportd(const unsigned short port)
|
||||
{
|
||||
register unsigned int result;
|
||||
asm volatile("ind %1, %0" : "=a" (result) : "dN" (port));
|
||||
return result;
|
||||
}
|
||||
|
||||
void kernaux_arch_i386_outportb(
|
||||
const unsigned short port,
|
||||
const unsigned char value
|
||||
) {
|
||||
asm volatile("outb %1, %0" : : "dN" (port), "a" (value));
|
||||
}
|
||||
|
||||
void kernaux_arch_i386_outportw(
|
||||
const unsigned short port,
|
||||
const unsigned short value
|
||||
) {
|
||||
asm volatile("outw %1, %0" : : "dN" (port), "a" (value));
|
||||
}
|
||||
|
||||
void kernaux_arch_i386_outportd(
|
||||
const unsigned short port,
|
||||
const unsigned int value
|
||||
) {
|
||||
asm volatile("outd %1, %0" : : "dN" (port), "a" (value));
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
76
include/kernaux/arch/x86.h
Normal file
76
include/kernaux/arch/x86.h
Normal file
|
@ -0,0 +1,76 @@
|
|||
#ifndef KERNAUX_INCLUDED_ARCH_X86
|
||||
#define KERNAUX_INCLUDED_ARCH_X86 1
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
inline static unsigned char kernaux_arch_x86_inportb(unsigned short port);
|
||||
inline static unsigned short kernaux_arch_x86_inportw(unsigned short port);
|
||||
inline static unsigned int kernaux_arch_x86_inportd(unsigned short port);
|
||||
|
||||
inline static void
|
||||
kernaux_arch_x86_outportb(unsigned short port, unsigned char value);
|
||||
|
||||
inline static void
|
||||
kernaux_arch_x86_outportw(unsigned short port, unsigned short value);
|
||||
|
||||
inline static void
|
||||
kernaux_arch_x86_outportd(unsigned short port, unsigned int value);
|
||||
|
||||
void kernaux_arch_x86_hang() __attribute__((noreturn));
|
||||
|
||||
unsigned long kernaux_arch_x86_read_cr0();
|
||||
unsigned long kernaux_arch_x86_read_cr4();
|
||||
|
||||
void kernaux_arch_x86_write_cr0(volatile unsigned long value);
|
||||
void kernaux_arch_x86_write_cr3(volatile unsigned long value);
|
||||
void kernaux_arch_x86_write_cr4(volatile unsigned long value);
|
||||
|
||||
unsigned char kernaux_arch_x86_inportb(const unsigned short port)
|
||||
{
|
||||
register unsigned char result;
|
||||
asm volatile("inb %1, %0" : "=a" (result) : "dN" (port));
|
||||
return result;
|
||||
}
|
||||
|
||||
unsigned short kernaux_arch_x86_inportw(const unsigned short port)
|
||||
{
|
||||
register unsigned short result;
|
||||
asm volatile("inw %1, %0" : "=a" (result) : "dN" (port));
|
||||
return result;
|
||||
}
|
||||
|
||||
unsigned int kernaux_arch_x86_inportd(const unsigned short port)
|
||||
{
|
||||
register unsigned int result;
|
||||
asm volatile("ind %1, %0" : "=a" (result) : "dN" (port));
|
||||
return result;
|
||||
}
|
||||
|
||||
void kernaux_arch_x86_outportb(
|
||||
const unsigned short port,
|
||||
const unsigned char value
|
||||
) {
|
||||
asm volatile("outb %1, %0" : : "dN" (port), "a" (value));
|
||||
}
|
||||
|
||||
void kernaux_arch_x86_outportw(
|
||||
const unsigned short port,
|
||||
const unsigned short value
|
||||
) {
|
||||
asm volatile("outw %1, %0" : : "dN" (port), "a" (value));
|
||||
}
|
||||
|
||||
void kernaux_arch_x86_outportd(
|
||||
const unsigned short port,
|
||||
const unsigned int value
|
||||
) {
|
||||
asm volatile("outd %1, %0" : : "dN" (port), "a" (value));
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -1,34 +0,0 @@
|
|||
.global kernaux_arch_i386_hang
|
||||
.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_hang:
|
||||
cli
|
||||
hlt
|
||||
jmp kernaux_arch_i386_hang
|
||||
|
||||
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
|
34
src/arch/x86.S
Normal file
34
src/arch/x86.S
Normal file
|
@ -0,0 +1,34 @@
|
|||
.global kernaux_arch_x86_hang
|
||||
.global kernaux_arch_x86_read_cr0
|
||||
.global kernaux_arch_x86_read_cr4
|
||||
.global kernaux_arch_x86_write_cr0
|
||||
.global kernaux_arch_x86_write_cr3
|
||||
.global kernaux_arch_x86_write_cr4
|
||||
|
||||
kernaux_arch_x86_hang:
|
||||
cli
|
||||
hlt
|
||||
jmp kernaux_arch_x86_hang
|
||||
|
||||
kernaux_arch_x86_read_cr0:
|
||||
mov %cr0, %eax
|
||||
ret
|
||||
|
||||
kernaux_arch_x86_read_cr4:
|
||||
mov %cr4, %eax
|
||||
ret
|
||||
|
||||
kernaux_arch_x86_write_cr0:
|
||||
mov 4(%esp), %eax
|
||||
mov %eax, %cr0
|
||||
ret
|
||||
|
||||
kernaux_arch_x86_write_cr3:
|
||||
mov 4(%esp), %eax
|
||||
mov %eax, %cr3
|
||||
ret
|
||||
|
||||
kernaux_arch_x86_write_cr4:
|
||||
mov 4(%esp), %eax
|
||||
mov %eax, %cr4
|
||||
ret
|
Loading…
Add table
Reference in a new issue