1
0
Fork 0
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:
Alex Kotov 2020-11-30 15:46:35 +05:00
parent e3b4a32272
commit d3aca7d855
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08
8 changed files with 127 additions and 127 deletions

View file

@ -22,8 +22,8 @@ libkernaux_a_SOURCES = \
src/pfa.c \ src/pfa.c \
src/stdlib.c src/stdlib.c
if ARCH_I386 if ARCH_X86
libkernaux_a_SOURCES += src/arch/i386.S libkernaux_a_SOURCES += src/arch/x86.S
endif endif
tests_multiboot2_print1_SOURCES = \ tests_multiboot2_print1_SOURCES = \

View file

@ -44,10 +44,10 @@ Configure with cross-compiler in `$PATH` to make without it in `$PATH`:
``` ```
./configure \ ./configure \
--host=i386-elf \ --host=x86-elf \
AR="$(which i386-elf-ar)" \ AR="$(which x86-elf-ar)" \
CC="$(which i386-elf-gcc)" \ CC="$(which x86-elf-gcc)" \
RANLIB="$(which i386-elf-ranlib)" \ RANLIB="$(which x86-elf-ranlib)" \
CFLAGS='-ffreestanding -nostdinc -nostdlib -fno-builtin -fno-stack-protector' 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-exec`
* `sudo make install-data` * `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: output something like this:
``` ```
src/arch/i386.o: file format elf32-i386 src/arch/x86.o: file format elf32-i386
Disassembly of section .text: Disassembly of section .text:
00000000 <kernaux_arch_i386_hang>: 00000000 <kernaux_arch_x86_hang>:
0: fa cli 0: fa cli
1: f4 hlt 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 4: 0f 20 c0 mov %cr0,%eax
7: c3 ret 7: c3 ret
00000008 <kernaux_arch_i386_read_cr4>: 00000008 <kernaux_arch_x86_read_cr4>:
8: 0f 20 e0 mov %cr4,%eax 8: 0f 20 e0 mov %cr4,%eax
b: c3 ret b: c3 ret
0000000c <kernaux_arch_i386_write_cr0>: 0000000c <kernaux_arch_x86_write_cr0>:
c: 8b 44 24 04 mov 0x4(%esp),%eax c: 8b 44 24 04 mov 0x4(%esp),%eax
10: 0f 22 c0 mov %eax,%cr0 10: 0f 22 c0 mov %eax,%cr0
13: c3 ret 13: c3 ret
00000014 <kernaux_arch_i386_write_cr3>: 00000014 <kernaux_arch_x86_write_cr3>:
14: 8b 44 24 04 mov 0x4(%esp),%eax 14: 8b 44 24 04 mov 0x4(%esp),%eax
18: 0f 22 d8 mov %eax,%cr3 18: 0f 22 d8 mov %eax,%cr3
1b: c3 ret 1b: c3 ret
0000001c <kernaux_arch_i386_write_cr4>: 0000001c <kernaux_arch_x86_write_cr4>:
1c: 8b 44 24 04 mov 0x4(%esp),%eax 1c: 8b 44 24 04 mov 0x4(%esp),%eax
20: 0f 22 e0 mov %eax,%cr4 20: 0f 22 e0 mov %eax,%cr4
23: c3 ret 23: c3 ret

View file

@ -9,7 +9,7 @@ AC_CONFIG_SRCDIR([src/pfa.c])
AC_CANONICAL_HOST 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]) AM_INIT_AUTOMAKE([1.9 subdir-objects -Wall -Werror])

View file

@ -1,5 +1,5 @@
nobase_include_HEADERS = \ nobase_include_HEADERS = \
kernaux/arch/i386.h \ kernaux/arch/x86.h \
kernaux/multiboot2.h \ kernaux/multiboot2.h \
kernaux/pfa.h \ kernaux/pfa.h \
kernaux/stdlib.h kernaux/stdlib.h

View file

@ -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

View 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

View file

@ -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
View 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