Add C header

This commit is contained in:
Mark 2020-09-27 11:57:35 +03:00
parent 1591988e76
commit 11e9556c8a
3 changed files with 56 additions and 0 deletions

54
include/protocol.h Normal file
View File

@ -0,0 +1,54 @@
// TODO: cbindgen doesn't work lmao
#pragma once
#include <stdint.h>
#define YB_CMDLINE_SIZE 256
#define YB_KERNEL_MAGIC_V1 {0x07, 0xB0, 0x07, 0xB0, 0xA9, 0x97, 0xA1, 0x00}
#define YB_LOADER_MAGIC_V1 {0x1A, 0x79, 0x9A, 0x0B, 0x70, 0x0B, 0x70, 0x00}
#define YB_FLAG_VIDEO (1 << 0)
#define YB_FLAG_INITRD (1 << 1)
#define YB_FLAG_UPPER (1 << 2)
struct yb_header {
uint8_t kernel_magic[8];
uint8_t loader_magic[8];
};
enum yb_pixel_format {
YB_LFB_BGR32 = 0,
YB_LFB_RGB32,
YB_LFB_ANY,
YB_TEXT
};
struct yb_video_info {
uint32_t width, height;
uint32_t format;
uint64_t framebuffer, pitch;
};
struct yb_memory_map_info {
uint64_t address;
uint32_t size, entsize;
};
struct yb_elf_tables {
uint64_t symtab_hdr, symtab_data;
uint64_t strtab_hdr, strtab_data;
};
struct yb_proto_v1 {
struct yb_header hdr;
uint32_t flags;
struct yb_video_info video;
struct yb_memory_map_info memory_map;
struct yb_elf_tables elf_tables;
uint64_t initrd_base, initrd_size;
uint64_t rsdp;
char cmdline[YB_CMDLINE_SIZE];
};

View File

@ -1,3 +1,4 @@
#[repr(C)]
pub struct MemoryMapInfo {
pub address: u64,
pub size: u32,

View File

@ -10,6 +10,7 @@ pub enum PixelFormat {
}
#[derive(Clone, Copy)]
#[repr(C)]
pub struct VideoInfo {
pub width: u32,
pub height: u32,