This repository has been archived on 2025-02-27. You can view files and clone it, but cannot push or open issues or pull requests.
portland-os/src/kernel/util.h
Benji Dial e8c6577617 program loading, others
big kernel additions: paging, elf loading, separate kernel and user page allocation
it now properly loads and runs sd0:bin/init.elf
still need to determine which disk was booted from, and start the init on that disk
2020-09-06 00:48:07 -04:00

54 lines
No EOL
1.2 KiB
C

#ifndef UTIL_H
#define UTIL_H
#include <stdint.h>
#include "drive.h"
static inline void outb(uint16_t port, uint8_t value) {
asm (
"outb %0, %1"
: : "a"(value), "Nd"(port));
}
static inline uint8_t inb(uint16_t port) {
volatile uint8_t value;
asm (
"inb %1, %0"
: "=a"(value) : "Nd"(port));
return value;
}
static inline void outw(uint16_t port, uint16_t value) {
asm (
"outw %0, %1"
: : "a"(value), "Nd"(port));
}
static inline uint16_t inw(uint16_t port) {
volatile uint16_t value;
asm (
"inw %1, %0"
: "=a"(value) : "Nd"(port));
return value;
}
static inline void outd(uint16_t port, uint32_t value) {
asm (
"outl %0, %1"
: : "a"(value), "Nd"(port));
}
static inline uint32_t ind(uint16_t port) {
volatile uint32_t value;
asm (
"inl %1, %0"
: "=a"(value) : "Nd"(port));
return value;
}
void memcpy(void *to, const void *from, uint32_t n);
void fmcpy(void *to, const struct drive *d, file_id_t f, uint32_t from, uint32_t n);
void u32_dec(uint32_t n, char *b);
void u16_dec(uint16_t n, char *b);
void u8_dec(uint8_t n, char *b);
void u32_hex(uint32_t n, char *b);
void u16_hex(uint16_t n, char *b);
void u8_hex(uint8_t n, char *b);
#endif