mirror of https://github.com/tailix/libkernaux.git
Use [u]int(8|16|32)_t from <stdint.h>
This commit is contained in:
parent
9636303f86
commit
745c403fa2
16
README.md
16
README.md
|
@ -85,11 +85,22 @@ You can test with `make check`.
|
||||||
|
|
||||||
### Cross
|
### Cross
|
||||||
|
|
||||||
|
The library depends on `stdint.h` header. According to the standards it must be
|
||||||
|
present in freestanding environment. However when you build GCC cross-compiler
|
||||||
|
using [instructions from OSDev Wiki](https://wiki.osdev.org/GCC_Cross-Compiler)
|
||||||
|
the header is missing. To fix this issue you may add `use_gcc_stdint=provide` to
|
||||||
|
the end of `gcc/config.gcc` in your GCC source code extracted from tarball:
|
||||||
|
|
||||||
|
```
|
||||||
|
echo 'use_gcc_stdint=provide' >> gcc-11.2.0/gcc/config.gcc
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
Create configuration script with `./autogen.sh`.
|
Create configuration script with `./autogen.sh`.
|
||||||
|
|
||||||
Let's assume that your target triplet is `i386-elf`. Configure with
|
Let's assume that your target triplet is `i386-elf`. Configure with
|
||||||
[cross-compiler](https://wiki.osdev.org/GCC_Cross-Compiler) in `$PATH` to make
|
cross-compiler in `$PATH` to make without it in `$PATH`:
|
||||||
without it in `$PATH`:
|
|
||||||
|
|
||||||
```
|
```
|
||||||
./configure \
|
./configure \
|
||||||
|
@ -233,3 +244,4 @@ SUM: 29 422 89 2186
|
||||||
* `stdarg.h`
|
* `stdarg.h`
|
||||||
* `stdbool.h`
|
* `stdbool.h`
|
||||||
* `stddef.h`
|
* `stddef.h`
|
||||||
|
* `stdint.h`
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
// TODO: Use [u]int(8|16|32)_t when problem with <stdint.h> is fixed.
|
|
||||||
|
|
||||||
#ifndef KERNAUX_INCLUDED_ARCH_I386
|
#ifndef KERNAUX_INCLUDED_ARCH_I386
|
||||||
#define KERNAUX_INCLUDED_ARCH_I386 1
|
#define KERNAUX_INCLUDED_ARCH_I386 1
|
||||||
|
|
||||||
|
@ -7,67 +5,58 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
inline static unsigned char kernaux_arch_i386_inportb(unsigned short port);
|
#include <stdint.h>
|
||||||
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
|
inline static uint8_t kernaux_arch_i386_inportb(uint16_t port);
|
||||||
kernaux_arch_i386_outportb(unsigned short port, unsigned char value);
|
inline static uint16_t kernaux_arch_i386_inportw(uint16_t port);
|
||||||
|
inline static uint32_t kernaux_arch_i386_inportd(uint16_t port);
|
||||||
|
|
||||||
inline static void
|
inline static void kernaux_arch_i386_outportb(uint16_t port, uint8_t value);
|
||||||
kernaux_arch_i386_outportw(unsigned short port, unsigned short value);
|
inline static void kernaux_arch_i386_outportw(uint16_t port, uint16_t value);
|
||||||
|
inline static void kernaux_arch_i386_outportd(uint16_t port, uint32_t value);
|
||||||
inline static void
|
|
||||||
kernaux_arch_i386_outportd(unsigned short port, unsigned int value);
|
|
||||||
|
|
||||||
void kernaux_arch_i386_hang() __attribute__((noreturn));
|
void kernaux_arch_i386_hang() __attribute__((noreturn));
|
||||||
|
|
||||||
unsigned long kernaux_arch_i386_read_cr0();
|
uint16_t kernaux_arch_i386_read_cr0();
|
||||||
unsigned long kernaux_arch_i386_read_cr4();
|
uint16_t kernaux_arch_i386_read_cr4();
|
||||||
|
|
||||||
void kernaux_arch_i386_write_cr0(volatile unsigned long value);
|
void kernaux_arch_i386_write_cr0(volatile uint16_t value);
|
||||||
void kernaux_arch_i386_write_cr3(volatile unsigned long value);
|
void kernaux_arch_i386_write_cr3(volatile uint16_t value);
|
||||||
void kernaux_arch_i386_write_cr4(volatile unsigned long value);
|
void kernaux_arch_i386_write_cr4(volatile uint16_t value);
|
||||||
|
|
||||||
unsigned char kernaux_arch_i386_inportb(const unsigned short port)
|
uint8_t kernaux_arch_i386_inportb(const uint16_t port)
|
||||||
{
|
{
|
||||||
register unsigned char result;
|
register uint8_t result;
|
||||||
__asm__ volatile("inb %1, %0" : "=a" (result) : "dN" (port));
|
__asm__ volatile("inb %1, %0" : "=a" (result) : "dN" (port));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned short kernaux_arch_i386_inportw(const unsigned short port)
|
uint16_t kernaux_arch_i386_inportw(const uint16_t port)
|
||||||
{
|
{
|
||||||
register unsigned short result;
|
register uint16_t result;
|
||||||
__asm__ volatile("inw %1, %0" : "=a" (result) : "dN" (port));
|
__asm__ volatile("inw %1, %0" : "=a" (result) : "dN" (port));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int kernaux_arch_i386_inportd(const unsigned short port)
|
uint32_t kernaux_arch_i386_inportd(const uint16_t port)
|
||||||
{
|
{
|
||||||
register unsigned int result;
|
register uint32_t result;
|
||||||
__asm__ volatile("ind %1, %0" : "=a" (result) : "dN" (port));
|
__asm__ volatile("ind %1, %0" : "=a" (result) : "dN" (port));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void kernaux_arch_i386_outportb(
|
void kernaux_arch_i386_outportb(const uint16_t port, const uint8_t value)
|
||||||
const unsigned short port,
|
{
|
||||||
const unsigned char value
|
|
||||||
) {
|
|
||||||
__asm__ volatile("outb %1, %0" : : "dN" (port), "a" (value));
|
__asm__ volatile("outb %1, %0" : : "dN" (port), "a" (value));
|
||||||
}
|
}
|
||||||
|
|
||||||
void kernaux_arch_i386_outportw(
|
void kernaux_arch_i386_outportw(const uint16_t port, const uint16_t value)
|
||||||
const unsigned short port,
|
{
|
||||||
const unsigned short value
|
|
||||||
) {
|
|
||||||
__asm__ volatile("outw %1, %0" : : "dN" (port), "a" (value));
|
__asm__ volatile("outw %1, %0" : : "dN" (port), "a" (value));
|
||||||
}
|
}
|
||||||
|
|
||||||
void kernaux_arch_i386_outportd(
|
void kernaux_arch_i386_outportd(const uint16_t port, const uint32_t value)
|
||||||
const unsigned short port,
|
{
|
||||||
const unsigned int value
|
|
||||||
) {
|
|
||||||
__asm__ volatile("outd %1, %0" : : "dN" (port), "a" (value));
|
__asm__ volatile("outd %1, %0" : : "dN" (port), "a" (value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue