mirror of
https://github.com/Leonmmcoset/cleonos.git
synced 2026-04-21 18:44:01 +00:00
初始化
This commit is contained in:
10
clks/include/clks/boot.h
Normal file
10
clks/include/clks/boot.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#ifndef CLKS_BOOT_H
|
||||
#define CLKS_BOOT_H
|
||||
|
||||
#include <clks/limine.h>
|
||||
#include <clks/types.h>
|
||||
|
||||
clks_bool clks_boot_base_revision_supported(void);
|
||||
const struct limine_framebuffer *clks_boot_get_framebuffer(void);
|
||||
|
||||
#endif
|
||||
17
clks/include/clks/compiler.h
Normal file
17
clks/include/clks/compiler.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifndef CLKS_COMPILER_H
|
||||
#define CLKS_COMPILER_H
|
||||
|
||||
#define CLKS_USED __attribute__((used))
|
||||
#define CLKS_NORETURN __attribute__((noreturn))
|
||||
#define CLKS_PACKED __attribute__((packed))
|
||||
#define CLKS_ALIGN(N) __attribute__((aligned(N)))
|
||||
|
||||
#if defined(CLKS_ARCH_X86_64) && defined(CLKS_ARCH_AARCH64)
|
||||
#error "Only one architecture can be selected"
|
||||
#endif
|
||||
|
||||
#if !defined(CLKS_ARCH_X86_64) && !defined(CLKS_ARCH_AARCH64)
|
||||
#error "Missing architecture define: CLKS_ARCH_X86_64 or CLKS_ARCH_AARCH64"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
24
clks/include/clks/cpu.h
Normal file
24
clks/include/clks/cpu.h
Normal file
@@ -0,0 +1,24 @@
|
||||
#ifndef CLKS_CPU_H
|
||||
#define CLKS_CPU_H
|
||||
|
||||
#include <clks/compiler.h>
|
||||
|
||||
static inline void clks_cpu_pause(void) {
|
||||
#if defined(CLKS_ARCH_X86_64)
|
||||
__asm__ volatile("pause");
|
||||
#elif defined(CLKS_ARCH_AARCH64)
|
||||
__asm__ volatile("yield");
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline CLKS_NORETURN void clks_cpu_halt_forever(void) {
|
||||
for (;;) {
|
||||
#if defined(CLKS_ARCH_X86_64)
|
||||
__asm__ volatile("hlt");
|
||||
#elif defined(CLKS_ARCH_AARCH64)
|
||||
__asm__ volatile("wfe");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
20
clks/include/clks/framebuffer.h
Normal file
20
clks/include/clks/framebuffer.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#ifndef CLKS_FRAMEBUFFER_H
|
||||
#define CLKS_FRAMEBUFFER_H
|
||||
|
||||
#include <clks/limine.h>
|
||||
#include <clks/types.h>
|
||||
|
||||
struct clks_framebuffer_info {
|
||||
u32 width;
|
||||
u32 height;
|
||||
u32 pitch;
|
||||
u16 bpp;
|
||||
};
|
||||
|
||||
void clks_fb_init(const struct limine_framebuffer *fb);
|
||||
clks_bool clks_fb_ready(void);
|
||||
struct clks_framebuffer_info clks_fb_info(void);
|
||||
void clks_fb_clear(u32 rgb);
|
||||
void clks_fb_draw_char(u32 x, u32 y, char ch, u32 fg_rgb, u32 bg_rgb);
|
||||
|
||||
#endif
|
||||
6
clks/include/clks/kernel.h
Normal file
6
clks/include/clks/kernel.h
Normal file
@@ -0,0 +1,6 @@
|
||||
#ifndef CLKS_KERNEL_H
|
||||
#define CLKS_KERNEL_H
|
||||
|
||||
void clks_kernel_main(void);
|
||||
|
||||
#endif
|
||||
56
clks/include/clks/limine.h
Normal file
56
clks/include/clks/limine.h
Normal file
@@ -0,0 +1,56 @@
|
||||
#ifndef CLKS_LIMINE_H
|
||||
#define CLKS_LIMINE_H
|
||||
|
||||
#include <clks/types.h>
|
||||
|
||||
#define LIMINE_COMMON_MAGIC 0xc7b1dd30df4c8b88ULL
|
||||
#define LIMINE_REQUEST_MAGIC 0x0a82e883a194f07bULL
|
||||
|
||||
#define LIMINE_REQUESTS_START_MARKER \
|
||||
{ 0xf6b8f4b39de7d1aeULL, 0xfab91a6940fcb9cfULL }
|
||||
|
||||
#define LIMINE_REQUESTS_END_MARKER \
|
||||
{ 0xadc0e0531bb10d03ULL, 0x9572709f31764c62ULL }
|
||||
|
||||
#define LIMINE_BASE_REVISION(N) \
|
||||
{ 0xf9562b2d5c95a6c8ULL, 0x6a7b384944536bdcULL, (N) }
|
||||
|
||||
#define LIMINE_FRAMEBUFFER_REQUEST \
|
||||
{ \
|
||||
LIMINE_COMMON_MAGIC, \
|
||||
LIMINE_REQUEST_MAGIC, \
|
||||
0x9d5827dcd881dd75ULL, \
|
||||
0xa3148604f6fab11bULL \
|
||||
}
|
||||
|
||||
struct limine_framebuffer {
|
||||
void *address;
|
||||
u64 width;
|
||||
u64 height;
|
||||
u64 pitch;
|
||||
u16 bpp;
|
||||
u8 memory_model;
|
||||
u8 red_mask_size;
|
||||
u8 red_mask_shift;
|
||||
u8 green_mask_size;
|
||||
u8 green_mask_shift;
|
||||
u8 blue_mask_size;
|
||||
u8 blue_mask_shift;
|
||||
u8 unused[7];
|
||||
u64 edid_size;
|
||||
void *edid;
|
||||
};
|
||||
|
||||
struct limine_framebuffer_response {
|
||||
u64 revision;
|
||||
u64 framebuffer_count;
|
||||
struct limine_framebuffer **framebuffers;
|
||||
};
|
||||
|
||||
struct limine_framebuffer_request {
|
||||
u64 id[4];
|
||||
u64 revision;
|
||||
struct limine_framebuffer_response *response;
|
||||
};
|
||||
|
||||
#endif
|
||||
16
clks/include/clks/log.h
Normal file
16
clks/include/clks/log.h
Normal file
@@ -0,0 +1,16 @@
|
||||
#ifndef CLKS_LOG_H
|
||||
#define CLKS_LOG_H
|
||||
|
||||
#include <clks/types.h>
|
||||
|
||||
enum clks_log_level {
|
||||
CLKS_LOG_DEBUG = 0,
|
||||
CLKS_LOG_INFO = 1,
|
||||
CLKS_LOG_WARN = 2,
|
||||
CLKS_LOG_ERROR = 3,
|
||||
};
|
||||
|
||||
void clks_log(enum clks_log_level level, const char *tag, const char *message);
|
||||
void clks_log_hex(enum clks_log_level level, const char *tag, const char *label, u64 value);
|
||||
|
||||
#endif
|
||||
8
clks/include/clks/serial.h
Normal file
8
clks/include/clks/serial.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#ifndef CLKS_SERIAL_H
|
||||
#define CLKS_SERIAL_H
|
||||
|
||||
void clks_serial_init(void);
|
||||
void clks_serial_write_char(char ch);
|
||||
void clks_serial_write(const char *text);
|
||||
|
||||
#endif
|
||||
12
clks/include/clks/string.h
Normal file
12
clks/include/clks/string.h
Normal file
@@ -0,0 +1,12 @@
|
||||
#ifndef CLKS_STRING_H
|
||||
#define CLKS_STRING_H
|
||||
|
||||
#include <clks/types.h>
|
||||
|
||||
usize clks_strlen(const char *str);
|
||||
void *clks_memset(void *dst, int value, usize count);
|
||||
void *clks_memcpy(void *dst, const void *src, usize count);
|
||||
void *clks_memmove(void *dst, const void *src, usize count);
|
||||
int clks_strcmp(const char *left, const char *right);
|
||||
|
||||
#endif
|
||||
12
clks/include/clks/tty.h
Normal file
12
clks/include/clks/tty.h
Normal file
@@ -0,0 +1,12 @@
|
||||
#ifndef CLKS_TTY_H
|
||||
#define CLKS_TTY_H
|
||||
|
||||
#include <clks/types.h>
|
||||
|
||||
void clks_tty_init(void);
|
||||
void clks_tty_write(const char *text);
|
||||
void clks_tty_write_char(char ch);
|
||||
void clks_tty_switch(u32 tty_index);
|
||||
u32 clks_tty_active(void);
|
||||
|
||||
#endif
|
||||
23
clks/include/clks/types.h
Normal file
23
clks/include/clks/types.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#ifndef CLKS_TYPES_H
|
||||
#define CLKS_TYPES_H
|
||||
|
||||
typedef unsigned char u8;
|
||||
typedef unsigned short u16;
|
||||
typedef unsigned int u32;
|
||||
typedef unsigned long long u64;
|
||||
|
||||
typedef signed char i8;
|
||||
typedef signed short i16;
|
||||
typedef signed int i32;
|
||||
typedef signed long long i64;
|
||||
|
||||
typedef u64 usize;
|
||||
|
||||
typedef enum clks_bool {
|
||||
CLKS_FALSE = 0,
|
||||
CLKS_TRUE = 1
|
||||
} clks_bool;
|
||||
|
||||
#define CLKS_NULL ((void *)0)
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user