- 用户态共享网络协议栈 CODE/tools/net_stack.h(eth/ARP/IPv4/ICMP/UDP-DNS/TCP static inline,轮询模型) - shell 内建 ping/curl/run 命令;ping.elf/curl.elf 对齐 net_stack.h 真实协议栈 - shell dev_mode 串口镜像(g_serial_mirror)便于自动化验证 - DSK 启动流程:firstInit.txt 双行格式(firstInit + dev_mode),dev_mode=1 触发 shell 自动回归测试 - FirstInit 完成→持久化 USER.CONF + 翻转 firstInit 0->1(保留 dev_mode) - firstInit=1 时 DSK 加载 login.elf 进行用户选择 + 密码校验后再进 desktop - 新增 CODE/login/ 登录应用、CODE/DKM/dkm_shared.h、Logo.png - ahci/e1000/virtio_net/fat32/console_fb 驱动更新;utsm serial/block/dsk_loader 调整 - build.ps1 打包 ping.elf/curl.elf 进 SATA FAT32 根目录 - 移除 CODE/tools/bash(与 shell.elf 重复)
108 lines
3.6 KiB
C
108 lines
3.6 KiB
C
/* DKM Console Framebuffer Driver
|
||
* Stage 1, optional, provides "console".
|
||
* Clears the framebuffer to a solid light-blue background so the screen is
|
||
* clean before DSK takes over and draws the Logo. The former 4-color arc
|
||
* loading ring has been removed — DSK now shows a static Logo instead.
|
||
*/
|
||
|
||
#include <stdint.h>
|
||
|
||
/* ---------------------------------------------------------------
|
||
* DKM ABI types
|
||
* --------------------------------------------------------------- */
|
||
#define DKM_DRIVER_MAGIC 0x444B4D31u
|
||
#define DKM_ABI_VERSION 1u
|
||
|
||
typedef unsigned char u8;
|
||
typedef unsigned short u16;
|
||
typedef unsigned int u32;
|
||
typedef unsigned long long u64;
|
||
typedef long long i64;
|
||
|
||
#define NULL ((void *)0)
|
||
|
||
struct dkm_log_api {
|
||
void (*info)(const char *msg);
|
||
void (*warn)(const char *msg);
|
||
void (*error)(const char *msg);
|
||
void (*panic)(const char *msg);
|
||
};
|
||
|
||
struct dkm_kernel_api {
|
||
u32 version; u32 size; u64 feature_bits;
|
||
const struct dkm_log_api *log;
|
||
const void *mem, *utsm, *irq, *pci_api, *dma, *vfs, *net, *timer, *drr;
|
||
const void *rsdp_address, *fb_address;
|
||
u64 fb_width, fb_height, fb_pitch; u16 fbpp;
|
||
};
|
||
|
||
struct dkm_driver_handle;
|
||
|
||
struct dkm_driver_desc {
|
||
u32 magic; u16 abi_version; u16 desc_size;
|
||
const char *name, *version, *vendor;
|
||
u32 driver_class, stage, flags, priority;
|
||
const char *const *depends; u32 depends_count;
|
||
const char *const *provides; u32 provides_count;
|
||
u64 min_kernel_abi, feature_bits, reserved0, reserved1;
|
||
};
|
||
|
||
static const char *const g_provides[] = { "console" };
|
||
|
||
__attribute__((visibility("default"), used))
|
||
const struct dkm_driver_desc driver_desc = {
|
||
.magic=DKM_DRIVER_MAGIC, .abi_version=DKM_ABI_VERSION,
|
||
.desc_size=sizeof(struct dkm_driver_desc),
|
||
.name="console_fb", .version="0.3.0", .vendor="Deshab",
|
||
.driver_class=5, .stage=1, .flags=0, .priority=0,
|
||
.depends=NULL, .depends_count=0,
|
||
.provides=g_provides, .provides_count=1,
|
||
.min_kernel_abi=1,
|
||
};
|
||
|
||
/* ---------------------------------------------------------------
|
||
* Colors
|
||
* --------------------------------------------------------------- */
|
||
static const u32 BG = 0xFFC8E0F0; /* light blue background — cleared before DSK Logo */
|
||
|
||
/* ---------------------------------------------------------------
|
||
* Drawing helpers – all integer arithmetic, no soft-float
|
||
* --------------------------------------------------------------- */
|
||
static void fb_fill(u32 *fb, u64 pitch, u64 w, u64 h, u32 color) {
|
||
for (u64 y = 0; y < h; y++) {
|
||
u32 *line = (u32 *)((u8 *)fb + y * pitch);
|
||
for (u64 x = 0; x < w; x++) line[x] = color;
|
||
}
|
||
}
|
||
|
||
/* ---------------------------------------------------------------
|
||
* Driver entry
|
||
* --------------------------------------------------------------- */
|
||
__attribute__((visibility("default")))
|
||
int driver_init(const struct dkm_kernel_api *api,
|
||
struct dkm_driver_handle *handle) {
|
||
(void)handle;
|
||
if (!api || !api->log) return -1;
|
||
if (!api->fb_address || !api->fb_width) {
|
||
api->log->warn("[console_fb] no framebuffer");
|
||
return 0;
|
||
}
|
||
|
||
api->log->info("[console_fb] clearing boot screen");
|
||
|
||
/* Solid background fill only — DSK draws the Logo next. Clearing here
|
||
* avoids firmware/UEFI leftover garbage being visible during the
|
||
* UTSM→DSK handoff. */
|
||
u32 *fb = (u32 *)api->fb_address;
|
||
fb_fill(fb, api->fb_pitch, api->fb_width, api->fb_height, BG);
|
||
|
||
api->log->info("[console_fb] ready");
|
||
return 0;
|
||
}
|
||
|
||
__attribute__((visibility("default")))
|
||
int driver_exit(struct dkm_driver_handle *handle) {
|
||
(void)handle;
|
||
return 0;
|
||
}
|