Issue 2 #3

Merged
patrick merged 5 commits from issue-2 into main 2026-06-05 18:59:06 +08:00
17 changed files with 79 additions and 59 deletions
Showing only changes of commit da03b301fb - Show all commits
+7 -7
View File
@@ -3,10 +3,10 @@
#include <graphics/draw.h> #include <graphics/draw.h>
#include <common.h> #include <common.h>
void pf_print_char(char c, unsigned int basex, unsigned int basey, EFI_GRAPHICS_OUTPUT_BLT_PIXEL color) { void pf_print_char(char c, SUINT32 basex, SUINT32 basey, EFI_GRAPHICS_OUTPUT_BLT_PIXEL color) {
for (unsigned int y = 0; y < 16; y++) { for (SUINT32 y = 0; y < 16; y++) {
unsigned char data = hankaku_pixels[c][y]; SUINT8 data = hankaku_pixels[c][y];
for (int x = 7; x >= 0; x--) { for (SSINT32 x = 7; x >= 0; x--) {
// 解码Hankaku字体 // 解码Hankaku字体
/* /*
既然都在这了,就讲一下Hankaku字体是如何解码的 既然都在这了,就讲一下Hankaku字体是如何解码的
@@ -14,7 +14,7 @@ void pf_print_char(char c, unsigned int basex, unsigned int basey, EFI_GRAPHICS_
{0x00, 0x82, 0x82, 0x44, 0x44, 0x44, 0x28, 0x28, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00} {0x00, 0x82, 0x82, 0x44, 0x44, 0x44, 0x28, 0x28, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00}
每一个Hex代表一行,比如0x82就是一行,转换成Bin得到10000010,1代表有像素,0代表没像素 每一个Hex代表一行,比如0x82就是一行,转换成Bin得到10000010,1代表有像素,0代表没像素
*/ */
unsigned int current = data & 1; SUINT32 current = data & 1;
data >>= 1; data >>= 1;
if (current) if (current)
draw_pixel(basex + x, basey + y, color); draw_pixel(basex + x, basey + y, color);
@@ -22,8 +22,8 @@ void pf_print_char(char c, unsigned int basex, unsigned int basey, EFI_GRAPHICS_
} }
} }
void pf_print(const char* text, unsigned int basex, unsigned int basey, EFI_GRAPHICS_OUTPUT_BLT_PIXEL color) { void pf_print(const char* text, SUINT32 basex, SUINT32 basey, EFI_GRAPHICS_OUTPUT_BLT_PIXEL color) {
for (unsigned int i = 0; i < strlen(text); i++) { for (SUINT32 i = 0; i < strlen(text); i++) {
char c = text[i]; char c = text[i];
pf_print_char(c, basex + i * 8, basey, color); // 只要 字数 * 8 + basex 不爆hr就没事 pf_print_char(c, basex + i * 8, basey, color); // 只要 字数 * 8 + basex 不爆hr就没事
} }
+1 -1
View File
@@ -24,7 +24,7 @@ void gfx_clear(void) {
g_gfx.GOP->Blt(g_gfx.GOP, &black, EfiBltVideoFill, 0, 0, 0, 0, g_gfx.hr, g_gfx.vr, 0); g_gfx.GOP->Blt(g_gfx.GOP, &black, EfiBltVideoFill, 0, 0, 0, 0, g_gfx.hr, g_gfx.vr, 0);
} }
void draw_set_target(EFI_GRAPHICS_OUTPUT_BLT_PIXEL *buf, unsigned int w, unsigned int h) { void draw_set_target(EFI_GRAPHICS_OUTPUT_BLT_PIXEL *buf, SUINT32 w, SUINT32 h) {
g_draw_target.buf = buf; g_draw_target.buf = buf;
g_draw_target.w = w; g_draw_target.w = w;
g_draw_target.h = h; g_draw_target.h = h;
+8 -8
View File
@@ -2,7 +2,7 @@
// --- Global (framebuffer) --- // --- Global (framebuffer) ---
void global_draw_pixel(unsigned int x, unsigned int y, EFI_GRAPHICS_OUTPUT_BLT_PIXEL color) { void global_draw_pixel(SUINT32 x, SUINT32 y, EFI_GRAPHICS_OUTPUT_BLT_PIXEL color) {
EFI_GRAPHICS_OUTPUT_BLT_PIXEL *p = g_gfx.base + (g_gfx.hr * y) + x; EFI_GRAPHICS_OUTPUT_BLT_PIXEL *p = g_gfx.base + (g_gfx.hr * y) + x;
p->Blue = color.Blue; p->Blue = color.Blue;
p->Green = color.Green; p->Green = color.Green;
@@ -10,16 +10,16 @@ void global_draw_pixel(unsigned int x, unsigned int y, EFI_GRAPHICS_OUTPUT_BLT_P
p->Reserved = color.Reserved; p->Reserved = color.Reserved;
} }
void global_draw_rect(unsigned int bx, unsigned int by, unsigned int ex, unsigned int ey, void global_draw_rect(SUINT32 bx, SUINT32 by, SUINT32 ex, SUINT32 ey,
EFI_GRAPHICS_OUTPUT_BLT_PIXEL color) { EFI_GRAPHICS_OUTPUT_BLT_PIXEL color) {
for (unsigned int x = bx; x <= ex; x++) for (SUINT32 x = bx; x <= ex; x++)
for (unsigned int y = by; y <= ey; y++) for (SUINT32 y = by; y <= ey; y++)
global_draw_pixel(x, y, color); global_draw_pixel(x, y, color);
} }
// --- Current target buffer --- // --- Current target buffer ---
void draw_pixel(unsigned int x, unsigned int y, EFI_GRAPHICS_OUTPUT_BLT_PIXEL color) { void draw_pixel(SUINT32 x, SUINT32 y, EFI_GRAPHICS_OUTPUT_BLT_PIXEL color) {
if (x >= g_draw_target.w || y >= g_draw_target.h) return; if (x >= g_draw_target.w || y >= g_draw_target.h) return;
EFI_GRAPHICS_OUTPUT_BLT_PIXEL *p = g_draw_target.buf + (g_draw_target.w * y) + x; EFI_GRAPHICS_OUTPUT_BLT_PIXEL *p = g_draw_target.buf + (g_draw_target.w * y) + x;
p->Blue = color.Blue; p->Blue = color.Blue;
@@ -28,9 +28,9 @@ void draw_pixel(unsigned int x, unsigned int y, EFI_GRAPHICS_OUTPUT_BLT_PIXEL co
p->Reserved = color.Reserved; p->Reserved = color.Reserved;
} }
void draw_rect(unsigned int bx, unsigned int by, unsigned int ex, unsigned int ey, void draw_rect(SUINT32 bx, SUINT32 by, SUINT32 ex, SUINT32 ey,
EFI_GRAPHICS_OUTPUT_BLT_PIXEL color) { EFI_GRAPHICS_OUTPUT_BLT_PIXEL color) {
for (unsigned int x = bx; x <= ex; x++) for (SUINT32 x = bx; x <= ex; x++)
for (unsigned int y = by; y <= ey; y++) for (SUINT32 y = by; y <= ey; y++)
draw_pixel(x, y, color); draw_pixel(x, y, color);
} }
+3 -2
View File
@@ -1,9 +1,10 @@
#pragma once #pragma once
#include <types.h>
#define ASM asm volatile #define ASM asm volatile
static unsigned int strlen(const char* arr) { // 获取string长度 static SUINT32 strlen(const char* arr) { // 获取string长度
int i = 0; SSINT32 i = 0;
while (arr[i++] != '\0'); while (arr[i++] != '\0');
return i - 1; return i - 1;
} }
+2 -1
View File
@@ -1,7 +1,8 @@
#pragma once #pragma once
#include <common.h>
// Hankaku 字体,不动 // Hankaku 字体,不动
static unsigned char hankaku_pixels[256][16] = { static SUINT8 hankaku_pixels[256][16] = {
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x10, 0x10, 0x38, 0x38, 0x7c, 0x7c, 0xfe, 0xfe, 0x7c, 0x7c, 0x38, 0x38, 0x10, 0x10, 0x00, 0x00}, {0x10, 0x10, 0x38, 0x38, 0x7c, 0x7c, 0xfe, 0xfe, 0x7c, 0x7c, 0x38, 0x38, 0x10, 0x10, 0x00, 0x00},
{0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x00, 0x00}, {0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x00, 0x00},
+2 -2
View File
@@ -2,6 +2,6 @@
#include <graphics/context.h> #include <graphics/context.h>
void pf_print_char(char c, unsigned int basex, unsigned int basey, void pf_print_char(char c, SUINT32 basex, SUINT32 basey,
EFI_GRAPHICS_OUTPUT_BLT_PIXEL color = {255, 255, 255, 255}); // Pixel Font 打印字符 EFI_GRAPHICS_OUTPUT_BLT_PIXEL color = {255, 255, 255, 255}); // Pixel Font 打印字符
void pf_print(const char* text, unsigned int basex, unsigned int basey, EFI_GRAPHICS_OUTPUT_BLT_PIXEL color = {255, 255, 255, 255}); // Pixel Font 打印string void pf_print(const char* text, SUINT32 basex, SUINT32 basey, EFI_GRAPHICS_OUTPUT_BLT_PIXEL color = {255, 255, 255, 255}); // Pixel Font 打印string
+6 -5
View File
@@ -3,11 +3,12 @@
// 这个文件存在的目的是让graphics的draw功能不用每次传 GOP hr vr base // 这个文件存在的目的是让graphics的draw功能不用每次传 GOP hr vr base
#include <efi.h> #include <efi.h>
#include <common.h>
struct gfx_context { struct gfx_context {
EFI_GRAPHICS_OUTPUT_PROTOCOL *GOP; EFI_GRAPHICS_OUTPUT_PROTOCOL *GOP;
unsigned int hr; SUINT32 hr;
unsigned int vr; SUINT32 vr;
EFI_GRAPHICS_OUTPUT_BLT_PIXEL *base; EFI_GRAPHICS_OUTPUT_BLT_PIXEL *base;
}; };
@@ -15,13 +16,13 @@ extern gfx_context g_gfx;
struct draw_target { struct draw_target {
EFI_GRAPHICS_OUTPUT_BLT_PIXEL *buf; EFI_GRAPHICS_OUTPUT_BLT_PIXEL *buf;
unsigned int w; SUINT32 w;
unsigned int h; SUINT32 h;
}; };
extern draw_target g_draw_target; extern draw_target g_draw_target;
void gfx_init(EFI_GRAPHICS_OUTPUT_PROTOCOL *GOP); void gfx_init(EFI_GRAPHICS_OUTPUT_PROTOCOL *GOP);
void gfx_clear(void); void gfx_clear(void);
void draw_set_target(EFI_GRAPHICS_OUTPUT_BLT_PIXEL *buf, unsigned int w, unsigned int h); void draw_set_target(EFI_GRAPHICS_OUTPUT_BLT_PIXEL *buf, SUINT32 w, SUINT32 h);
void draw_set_default_target(void); void draw_set_default_target(void);
+4 -4
View File
@@ -3,10 +3,10 @@
#include <efi.h> #include <efi.h>
#include <graphics/context.h> #include <graphics/context.h>
void global_draw_pixel(unsigned int x, unsigned int y, EFI_GRAPHICS_OUTPUT_BLT_PIXEL color); void global_draw_pixel(SUINT32 x, SUINT32 y, EFI_GRAPHICS_OUTPUT_BLT_PIXEL color);
void global_draw_rect(unsigned int bx, unsigned int by, unsigned int ex, unsigned int ey, void global_draw_rect(SUINT32 bx, SUINT32 by, SUINT32 ex, SUINT32 ey,
EFI_GRAPHICS_OUTPUT_BLT_PIXEL color); EFI_GRAPHICS_OUTPUT_BLT_PIXEL color);
void draw_pixel(unsigned int x, unsigned int y, EFI_GRAPHICS_OUTPUT_BLT_PIXEL color); void draw_pixel(SUINT32 x, SUINT32 y, EFI_GRAPHICS_OUTPUT_BLT_PIXEL color);
void draw_rect(unsigned int bx, unsigned int by, unsigned int ex, unsigned int ey, void draw_rect(SUINT32 bx, SUINT32 by, SUINT32 ex, SUINT32 ey,
EFI_GRAPHICS_OUTPUT_BLT_PIXEL color); EFI_GRAPHICS_OUTPUT_BLT_PIXEL color);
+5 -4
View File
@@ -1,6 +1,7 @@
#pragma once #pragma once
#include <efi.h> #include <efi.h>
#include <common.h>
#define LAYER_MAX 32 #define LAYER_MAX 32
#define LAYER_NAME_LEN 32 #define LAYER_NAME_LEN 32
@@ -16,9 +17,9 @@ typedef struct layer {
UINT32 id; UINT32 id;
char name[LAYER_NAME_LEN]; char name[LAYER_NAME_LEN];
layer_type_t type; layer_type_t type;
int x, y; SSINT32 x, y;
UINT32 w, h; UINT32 w, h;
int z; SSINT32 z;
bool visible; bool visible;
EFI_GRAPHICS_OUTPUT_BLT_PIXEL* buffer; EFI_GRAPHICS_OUTPUT_BLT_PIXEL* buffer;
struct layer* next; struct layer* next;
@@ -30,8 +31,8 @@ void layer_init(void);
// Layer management // Layer management
layer_t* layer_create(const char* name, layer_type_t type, UINT32 w, UINT32 h); layer_t* layer_create(const char* name, layer_type_t type, UINT32 w, UINT32 h);
void layer_destroy(layer_t* layer); void layer_destroy(layer_t* layer);
void layer_set_z(layer_t* layer, int z); void layer_set_z(layer_t* layer, SSINT32 z);
void layer_set_pos(layer_t* layer, int x, int y); void layer_set_pos(layer_t* layer, SSINT32 x, SSINT32 y);
void layer_set_visible(layer_t* layer, bool visible); void layer_set_visible(layer_t* layer, bool visible);
layer_t* layer_get_by_id(UINT32 id); layer_t* layer_get_by_id(UINT32 id);
layer_t* layer_get_focused(void); layer_t* layer_get_focused(void);
+15
View File
@@ -0,0 +1,15 @@
#pragma once
#include <stdint.h>
// Signed integers
#define SSINT8 int8_t
#define SSINT16 int16_t
#define SSINT32 int32_t
#define SSINT64 int64_t
// Unsigned integers
#define SUINT8 uint8_t
#define SUINT16 uint16_t
#define SUINT32 uint32_t
#define SUINT64 uint64_t
+11 -11
View File
@@ -216,7 +216,7 @@ static EFI_STATUS find_mbr_partition(struct block_dev *dev, UINT64 *StartLBA) {
struct MBRPart *Parts = (struct MBRPart*)(Buf + 446); struct MBRPart *Parts = (struct MBRPart*)(Buf + 446);
// Verify at least one non-zero partition entry exists // Verify at least one non-zero partition entry exists
BOOLEAN has_part = FALSE; BOOLEAN has_part = FALSE;
for (int i = 0; i < 4; i++) { for (SSINT32 i = 0; i < 4; i++) {
if (Parts[i].Type != 0x00 && Parts[i].Type != 0xEE) { if (Parts[i].Type != 0x00 && Parts[i].Type != 0xEE) {
has_part = TRUE; has_part = TRUE;
break; break;
@@ -224,7 +224,7 @@ static EFI_STATUS find_mbr_partition(struct block_dev *dev, UINT64 *StartLBA) {
} }
if (!has_part) { kfree(Buf); return EFI_NOT_FOUND; } if (!has_part) { kfree(Buf); return EFI_NOT_FOUND; }
for (int i = 0; i < 4; i++) { for (SSINT32 i = 0; i < 4; i++) {
UINT8 t = Parts[i].Type; UINT8 t = Parts[i].Type;
if (t == 0x00 || t == 0xEE) continue; if (t == 0x00 || t == 0xEE) continue;
if (t == MBR_TYPE_FAT12 || t == MBR_TYPE_FAT16 || if (t == MBR_TYPE_FAT12 || t == MBR_TYPE_FAT16 ||
@@ -238,7 +238,7 @@ static EFI_STATUS find_mbr_partition(struct block_dev *dev, UINT64 *StartLBA) {
} }
// Fallback: first non-empty partition // Fallback: first non-empty partition
for (int i = 0; i < 4; i++) { for (SSINT32 i = 0; i < 4; i++) {
if (Parts[i].Type != 0x00) { if (Parts[i].Type != 0x00) {
*StartLBA = Parts[i].LBABegin; *StartLBA = Parts[i].LBABegin;
kfree(Buf); kfree(Buf);
@@ -361,7 +361,7 @@ static EFI_STATUS fat_init(struct fat_fs *fs, struct block_dev *dev, UINT64 Part
static UINT8 lfn_checksum(const UINT8 *SFN) { static UINT8 lfn_checksum(const UINT8 *SFN) {
UINT8 sum = 0; UINT8 sum = 0;
for (int i = 0; i < 11; i++) for (SSINT32 i = 0; i < 11; i++)
sum = ((sum & 1) ? 0x80 : 0) + (sum >> 1) + SFN[i]; sum = ((sum & 1) ? 0x80 : 0) + (sum >> 1) + SFN[i];
return sum; return sum;
} }
@@ -381,17 +381,17 @@ static void lfn_reset(struct lfn_state *lfn) {
static void lfn_add(struct lfn_state *lfn, const UINT8 *E) { static void lfn_add(struct lfn_state *lfn, const UINT8 *E) {
if (lfn->count >= LFN_MAX_FRAGS) return; if (lfn->count >= LFN_MAX_FRAGS) return;
UINTN pos = 0; UINTN pos = 0;
for (int i = 0; i < 5 && pos < LFN_FRAG_SIZE; i++) { for (SSINT32 i = 0; i < 5 && pos < LFN_FRAG_SIZE; i++) {
CHAR16 c = *(const UINT16*)(E + 1 + i * 2); CHAR16 c = *(const UINT16*)(E + 1 + i * 2);
if (c == 0x0000 || c == 0xFFFF) { lfn->frags[lfn->count][pos] = 0; return; } if (c == 0x0000 || c == 0xFFFF) { lfn->frags[lfn->count][pos] = 0; return; }
lfn->frags[lfn->count][pos++] = c; lfn->frags[lfn->count][pos++] = c;
} }
for (int i = 0; i < 6 && pos < LFN_FRAG_SIZE; i++) { for (SSINT32 i = 0; i < 6 && pos < LFN_FRAG_SIZE; i++) {
CHAR16 c = *(const UINT16*)(E + 14 + i * 2); CHAR16 c = *(const UINT16*)(E + 14 + i * 2);
if (c == 0x0000 || c == 0xFFFF) { lfn->frags[lfn->count][pos] = 0; return; } if (c == 0x0000 || c == 0xFFFF) { lfn->frags[lfn->count][pos] = 0; return; }
lfn->frags[lfn->count][pos++] = c; lfn->frags[lfn->count][pos++] = c;
} }
for (int i = 0; i < 2 && pos < LFN_FRAG_SIZE; i++) { for (SSINT32 i = 0; i < 2 && pos < LFN_FRAG_SIZE; i++) {
CHAR16 c = *(const UINT16*)(E + 28 + i * 2); CHAR16 c = *(const UINT16*)(E + 28 + i * 2);
if (c == 0x0000 || c == 0xFFFF) { lfn->frags[lfn->count][pos] = 0; return; } if (c == 0x0000 || c == 0xFFFF) { lfn->frags[lfn->count][pos] = 0; return; }
lfn->frags[lfn->count][pos++] = c; lfn->frags[lfn->count][pos++] = c;
@@ -413,11 +413,11 @@ static void lfn_build(struct lfn_state *lfn, CHAR16 *out, UINTN out_size) {
static void sfn_to_name(const UINT8 *E, CHAR16 *out, UINTN out_size) { static void sfn_to_name(const UINT8 *E, CHAR16 *out, UINTN out_size) {
UINTN pos = 0; UINTN pos = 0;
for (int i = 0; i < 8 && pos < out_size - 1; i++) for (SSINT32 i = 0; i < 8 && pos < out_size - 1; i++)
if (E[i] != ' ') out[pos++] = E[i]; if (E[i] != ' ') out[pos++] = E[i];
UINTN ext_start = pos; UINTN ext_start = pos;
BOOLEAN has_ext = FALSE; BOOLEAN has_ext = FALSE;
for (int i = 8; i < 11 && pos < out_size - 1; i++) { for (SSINT32 i = 8; i < 11 && pos < out_size - 1; i++) {
if (E[i] != ' ') { if (E[i] != ' ') {
if (!has_ext) { out[pos++] = '.'; has_ext = TRUE; ext_start = pos; } if (!has_ext) { out[pos++] = '.'; has_ext = TRUE; ext_start = pos; }
out[pos++] = E[i]; out[pos++] = E[i];
@@ -533,7 +533,7 @@ static BOOLEAN g_fs_inited = FALSE;
struct list_ctx { struct list_ctx {
struct fat_fs *fs; struct fat_fs *fs;
int depth; SSINT32 depth;
}; };
static void name_to_ascii(const CHAR16 *Name, char *Ascii, UINTN ascii_sz) { static void name_to_ascii(const CHAR16 *Name, char *Ascii, UINTN ascii_sz) {
@@ -550,7 +550,7 @@ static void name_to_ascii(const CHAR16 *Name, char *Ascii, UINTN ascii_sz) {
static void list_callback(void *ctx, const CHAR16 *Name, UINT8 Attr, static void list_callback(void *ctx, const CHAR16 *Name, UINT8 Attr,
UINT32 Size, UINT32 FirstClus) { UINT32 Size, UINT32 FirstClus) {
struct list_ctx *lc = (struct list_ctx*)ctx; struct list_ctx *lc = (struct list_ctx*)ctx;
for (int i = 0; i < lc->depth; i++) serial_write(" "); for (SSINT32 i = 0; i < lc->depth; i++) serial_write(" ");
serial_write(Attr & 0x10 ? "[DIR] " : "[FILE] "); serial_write(Attr & 0x10 ? "[DIR] " : "[FILE] ");
+7 -7
View File
@@ -86,7 +86,7 @@ layer_t* layer_create(const char* name, layer_type_t type, UINT32 w, UINT32 h) {
const char* s = name; const char* s = name;
char* d = layer->name; char* d = layer->name;
for (int i = 0; i < LAYER_NAME_LEN - 1 && *s; i++) { for (SSINT32 i = 0; i < LAYER_NAME_LEN - 1 && *s; i++) {
*d++ = *s++; *d++ = *s++;
} }
*d = '\0'; *d = '\0';
@@ -149,14 +149,14 @@ layer_t* layer_get_focused(void) {
return g_focused; return g_focused;
} }
void layer_set_z(layer_t* layer, int z) { void layer_set_z(layer_t* layer, SSINT32 z) {
if (!layer) return; if (!layer) return;
layer_remove(layer); layer_remove(layer);
layer->z = z; layer->z = z;
layer_insert_sorted(layer); layer_insert_sorted(layer);
} }
void layer_set_pos(layer_t* layer, int x, int y) { void layer_set_pos(layer_t* layer, SSINT32 x, SSINT32 y) {
if (!layer) return; if (!layer) return;
layer->x = x; layer->x = x;
layer->y = y; layer->y = y;
@@ -281,14 +281,14 @@ void layer_compositor_task(void) {
layer_t* cur = g_layer_list; layer_t* cur = g_layer_list;
while (cur) { while (cur) {
if (cur->visible && cur->buffer) { if (cur->visible && cur->buffer) {
int sx = 0, sy = 0; SSINT32 sx = 0, sy = 0;
int dx = cur->x, dy = cur->y; SSINT32 dx = cur->x, dy = cur->y;
UINT32 sw = cur->w, sh = cur->h; UINT32 sw = cur->w, sh = cur->h;
if (dx < 0) { sx = -dx; sw -= sx; dx = 0; } if (dx < 0) { sx = -dx; sw -= sx; dx = 0; }
if (dy < 0) { sy = -dy; sh -= sy; dy = 0; } if (dy < 0) { sy = -dy; sh -= sy; dy = 0; }
if (dx + (int)sw > (int)hr) sw = hr - dx; if (dx + (SSINT32)sw > (SSINT32)hr) sw = hr - dx;
if (dy + (int)sh > (int)vr) sh = vr - dy; if (dy + (SSINT32)sh > (SSINT32)vr) sh = vr - dy;
if (sw == 0 || sh == 0) { cur = cur->next; continue; } if (sw == 0 || sh == 0) { cur = cur->next; continue; }
for (UINT32 row = 0; row < sh; row++) { for (UINT32 row = 0; row < sh; row++) {
+1 -1
View File
@@ -41,7 +41,7 @@ static void tss_set_descriptor(UINT32 index) {
void gdt_init(void) { void gdt_init(void) {
serial_write("GDT: initializing\n"); serial_write("GDT: initializing\n");
for (int i = 0; i < 7; i++) { for (SSINT32 i = 0; i < 7; i++) {
g_gdt[i] = {0}; g_gdt[i] = {0};
} }
+2 -2
View File
@@ -47,13 +47,13 @@ void idt_init(void) {
serial_write("IDT: initializing 256 entries\n"); serial_write("IDT: initializing 256 entries\n");
// Clear IDT // Clear IDT
for (int i = 0; i < 256; i++) { for (SSINT32 i = 0; i < 256; i++) {
g_idt[i] = {0}; g_idt[i] = {0};
g_handlers[i] = NULL; g_handlers[i] = NULL;
} }
// Install all 256 ISR stubs // Install all 256 ISR stubs
for (int i = 0; i < 256; i++) { for (SSINT32 i = 0; i < 256; i++) {
idt_set_entry(i, (UINT64)isr_stub_table[i]); idt_set_entry(i, (UINT64)isr_stub_table[i]);
} }
+2 -2
View File
@@ -173,7 +173,7 @@ extern "C" void kernel_main() {
// Create window 1 (centered) // Create window 1 (centered)
layer_t* win1 = layer_create("window_1", LAYER_TYPE_WINDOW, 300, 200); layer_t* win1 = layer_create("window_1", LAYER_TYPE_WINDOW, 300, 200);
if (win1) { if (win1) {
layer_set_pos(win1, (int)(g_gfx.hr / 2) - 150, (int)(g_gfx.vr / 2) - 100); layer_set_pos(win1, (SSINT32)(g_gfx.hr / 2) - 150, (SSINT32)(g_gfx.vr / 2) - 100);
layer_set_z(win1, 1); layer_set_z(win1, 1);
EFI_GRAPHICS_OUTPUT_BLT_PIXEL win_color = {200, 200, 200, 0}; EFI_GRAPHICS_OUTPUT_BLT_PIXEL win_color = {200, 200, 200, 0};
draw_set_target(win1->buffer, 300, 200); draw_set_target(win1->buffer, 300, 200);
@@ -184,7 +184,7 @@ extern "C" void kernel_main() {
// Create window 2 (offset from center) // Create window 2 (offset from center)
layer_t* win2 = layer_create("window_2", LAYER_TYPE_WINDOW, 250, 180); layer_t* win2 = layer_create("window_2", LAYER_TYPE_WINDOW, 250, 180);
if (win2) { if (win2) {
layer_set_pos(win2, (int)(g_gfx.hr / 2) - 50, (int)(g_gfx.vr / 2) - 40); layer_set_pos(win2, (SSINT32)(g_gfx.hr / 2) - 50, (SSINT32)(g_gfx.vr / 2) - 40);
layer_set_z(win2, 2); layer_set_z(win2, 2);
EFI_GRAPHICS_OUTPUT_BLT_PIXEL win2_color = {180, 220, 140, 0}; EFI_GRAPHICS_OUTPUT_BLT_PIXEL win2_color = {180, 220, 140, 0};
draw_set_target(win2->buffer, 250, 180); draw_set_target(win2->buffer, 250, 180);
+1 -1
View File
@@ -55,7 +55,7 @@ task_t* task_create(const char* name, void (*entry)(void)) {
// Copy name // Copy name
const char* s = name; const char* s = name;
char* d = task->name; char* d = task->name;
for (int i = 0; i < TASK_NAME_LEN - 1 && *s; i++) { for (SSINT32 i = 0; i < TASK_NAME_LEN - 1 && *s; i++) {
*d++ = *s++; *d++ = *s++;
} }
*d = '\0'; *d = '\0';
+2 -1
View File
@@ -1,4 +1,5 @@
#include <serial.h> #include <serial.h>
#include <common.h>
extern EFI_SYSTEM_TABLE *ST; extern EFI_SYSTEM_TABLE *ST;
@@ -34,7 +35,7 @@ void serial_write(const char *str) {
void serial_write_hex(UINTN val) { void serial_write_hex(UINTN val) {
char buf[19]; char buf[19];
buf[0] = '0'; buf[1] = 'x'; buf[0] = '0'; buf[1] = 'x';
for (int i = 17; i >= 2; i--) { for (SSINT32 i = 17; i >= 2; i--) {
UINTN digit = val & 0xF; UINTN digit = val & 0xF;
buf[i] = digit < 10 ? '0' + digit : 'A' + digit - 10; buf[i] = digit < 10 ? '0' + digit : 'A' + digit - 10;
val >>= 4; val >>= 4;