First commit, Vystem v0.1

This commit is contained in:
2026-03-31 22:15:00 +02:00
commit e15daed8c0
462 changed files with 134655 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
// SPDX-License-Identifier: MPL-2.0
#ifndef SH_LIB_ASM_H
#define SH_LIB_ASM_H
#include "std/type.h"
#include "std/status.h"
// inb instruction wrapper
static inline sh_uint8 sh_asm_inb(sh_uint16 port) {
sh_uint8 val;
__asm__ volatile ("inb %1, %0":"=a"(val):"Nd"(port));
return val;
}
// outb instruction wrapper
static inline void sh_asm_outb(sh_uint16 port,sh_uint8 val) {
__asm__ volatile ("outb %0, %1"::"a"(val),"Nd"(port));
}
// rdtsc instruction wrapper
static inline sh_uint64 sh_asm_rdtsc() {
sh_uint32 lo,hi;
__asm__ volatile ("rdtsc":"=a"(lo),"=d"(hi));
return ((sh_uint64)hi<<32)|lo;
}
// invlpg instruction wrapper
static inline void sh_asm_invlpg(void *addr) {
__asm__ volatile ("invlpg (%0)"::"r"(addr):"memory");
}
#endif

View File

@@ -0,0 +1,11 @@
// SPDX-License-Identifier: MPL-2.0
#ifndef SH_LIB_SERIAL_H
#define SH_LIB_SERIAL_H
#include "std/type.h"
#include "std/status.h"
#define SH_SERIAL_PORT_COM1 0x3F8
// Load serial port setting
void sh_serial_load_serial_port_setting(sh_bool is_disabled);
// Send safely (wait for (SH_SERIAL_PORT_COM1+5) & 0x20 to be at 1) a byte
void sh_serial_send_byte(sh_uint8 b);
#endif

View File

@@ -0,0 +1,18 @@
// SPDX-License-Identifier: MPL-2.0
#ifndef SH_LIB_TSC_H
#define SH_LIB_TSC_H
#include "std/type.h"
#include "std/status.h"
#include "cpu/asm.h"
typedef sh_uint64 sh_tsc_TSC_VALUE;
// Reas TSC register.
static inline sh_tsc_TSC_VALUE sh_tsc_read_tsc() {
return sh_asm_rdtsc();
}
// Init kernel start tsc. Intended for single use only.
SH_STATUS sh_tsc_init_tsc();
// Return kernel start tsc.
sh_tsc_TSC_VALUE sh_tsc_get_kernel_init_tsc();
// Return kernel current tsc.
sh_tsc_TSC_VALUE sh_tsc_get_kernel_current_tsc();
#endif