mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-10 08:06:48 +00:00
完成了屏幕管理器的框架
This commit is contained in:
parent
0dedafe1cd
commit
602ec281a6
@ -6,6 +6,8 @@
|
|||||||
#include <driver/multiboot2/multiboot2.h>
|
#include <driver/multiboot2/multiboot2.h>
|
||||||
#include <mm/mm.h>
|
#include <mm/mm.h>
|
||||||
#include <common/spinlock.h>
|
#include <common/spinlock.h>
|
||||||
|
#include <lib/libUI/textui.h>
|
||||||
|
#include <lib/libUI/screen_manager.h>
|
||||||
|
|
||||||
#include <driver/uart/uart.h>
|
#include <driver/uart/uart.h>
|
||||||
#include <driver/video/video.h>
|
#include <driver/video/video.h>
|
||||||
@ -13,7 +15,7 @@
|
|||||||
#include <common/string.h>
|
#include <common/string.h>
|
||||||
|
|
||||||
struct printk_screen_info pos;
|
struct printk_screen_info pos;
|
||||||
extern ul VBE_FB_phys_addr; // 由bootloader传来的帧缓存区的物理地址
|
|
||||||
static spinlock_t printk_lock;
|
static spinlock_t printk_lock;
|
||||||
static bool sw_show_scroll_animation = false; // 显示换行动画的开关
|
static bool sw_show_scroll_animation = false; // 显示换行动画的开关
|
||||||
|
|
||||||
@ -81,24 +83,18 @@ static int calculate_max_charNum(int len, int size)
|
|||||||
return len / size - 1;
|
return len / size - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int printk_init(const int char_size_x, const int char_size_y)
|
int printk_init(struct scm_buffer_info_t *buf)
|
||||||
{
|
{
|
||||||
struct multiboot_tag_framebuffer_info_t info;
|
|
||||||
int reserved;
|
|
||||||
|
|
||||||
multiboot2_iter(multiboot2_get_Framebuffer_info, &info, &reserved);
|
pos.width = buf->width;
|
||||||
|
pos.height = buf->height;
|
||||||
|
|
||||||
pos.width = info.framebuffer_width;
|
pos.char_size_x = 8;
|
||||||
pos.height = info.framebuffer_height;
|
pos.char_size_y = 16;
|
||||||
|
pos.max_x = calculate_max_charNum(pos.width, pos.char_size_x);
|
||||||
|
pos.max_y = calculate_max_charNum(pos.height, pos.char_size_y);
|
||||||
|
|
||||||
pos.char_size_x = char_size_x;
|
pos.FB_address = buf->vaddr;
|
||||||
pos.char_size_y = char_size_y;
|
|
||||||
pos.max_x = calculate_max_charNum(pos.width, char_size_x);
|
|
||||||
pos.max_y = calculate_max_charNum(pos.height, char_size_y);
|
|
||||||
|
|
||||||
VBE_FB_phys_addr = (ul)info.framebuffer_addr;
|
|
||||||
|
|
||||||
pos.FB_address = (uint *)0xffff800003000000;
|
|
||||||
pos.FB_length = 1UL * pos.width * pos.height;
|
pos.FB_length = 1UL * pos.width * pos.height;
|
||||||
|
|
||||||
// 初始化自旋锁
|
// 初始化自旋锁
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
|
|
||||||
#include "font.h"
|
#include "font.h"
|
||||||
#include "glib.h"
|
#include "glib.h"
|
||||||
//#include "linkage.h"
|
#include <lib/libUI/screen_manager.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
struct printk_screen_info
|
struct printk_screen_info
|
||||||
@ -61,7 +61,7 @@ extern unsigned char font_ascii[256][16]; //导出ascii字体的bitmap(8*16大
|
|||||||
* @param char_size_x 字符的列坐标
|
* @param char_size_x 字符的列坐标
|
||||||
* @param char_size_y 字符的行坐标
|
* @param char_size_y 字符的行坐标
|
||||||
*/
|
*/
|
||||||
int printk_init(const int char_size_x, const int char_size_y);
|
int printk_init(struct scm_buffer_info_t* buf);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 将字符串按照fmt和args中的内容进行格式化,然后保存到buf中
|
* @brief 将字符串按照fmt和args中的内容进行格式化,然后保存到buf中
|
||||||
|
@ -22,7 +22,6 @@ static struct scm_buffer_info_t *video_refresh_target = NULL;
|
|||||||
|
|
||||||
#define REFRESH_INTERVAL 15UL // 启动刷新帧缓冲区任务的时间间隔
|
#define REFRESH_INTERVAL 15UL // 启动刷新帧缓冲区任务的时间间隔
|
||||||
|
|
||||||
ul VBE_FB_phys_addr; // 由bootloader传来的帧缓存区的物理地址
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief VBE帧缓存区的地址重新映射
|
* @brief VBE帧缓存区的地址重新映射
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
|
|
||||||
all: screen_manager.o
|
all: screen_manager.o textui.o
|
||||||
|
|
||||||
CFLAGS += -I .
|
CFLAGS += -I .
|
||||||
|
|
||||||
screen_manager.o: screen_manager.c
|
screen_manager.o: screen_manager.c
|
||||||
gcc $(CFLAGS) -c screen_manager.c -o screen_manager.o
|
gcc $(CFLAGS) -c screen_manager.c -o screen_manager.o
|
||||||
|
|
||||||
|
textui.o: textui.c
|
||||||
|
gcc $(CFLAGS) -c textui.c -o textui.o
|
@ -1,4 +1,5 @@
|
|||||||
#include "screen_manager.h"
|
#include "screen_manager.h"
|
||||||
|
#include <common/string.h>
|
||||||
#include <driver/multiboot2/multiboot2.h>
|
#include <driver/multiboot2/multiboot2.h>
|
||||||
#include <common/kprint.h>
|
#include <common/kprint.h>
|
||||||
#include <common/spinlock.h>
|
#include <common/spinlock.h>
|
||||||
@ -7,13 +8,6 @@
|
|||||||
#include <driver/uart/uart.h>
|
#include <driver/uart/uart.h>
|
||||||
#include <driver/video/video.h>
|
#include <driver/video/video.h>
|
||||||
|
|
||||||
extern const struct scm_buffer_info_t video_frame_buffer_info;
|
|
||||||
static struct List scm_framework_list;
|
|
||||||
static spinlock_t scm_register_lock; // 框架注册锁
|
|
||||||
static uint32_t scm_ui_max_id = 0;
|
|
||||||
static bool __scm_alloc_enabled = false; // 允许动态申请内存的标志位
|
|
||||||
static bool __scm_double_buffer_enabled = false; // 允许双缓冲的标志位
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 初始化屏幕管理模块
|
* @brief 初始化屏幕管理模块
|
||||||
*
|
*
|
||||||
@ -21,6 +15,14 @@ static bool __scm_double_buffer_enabled = false; // 允许双缓冲的标志位
|
|||||||
#pragma GCC push_options
|
#pragma GCC push_options
|
||||||
#pragma GCC optimize("O0")
|
#pragma GCC optimize("O0")
|
||||||
|
|
||||||
|
extern struct scm_buffer_info_t video_frame_buffer_info;
|
||||||
|
static struct List scm_framework_list;
|
||||||
|
static spinlock_t scm_register_lock; // 框架注册锁
|
||||||
|
static spinlock_t scm_screen_own_lock = {1}; // 改变屏幕归属者时,需要对该锁加锁
|
||||||
|
static struct scm_ui_framework_t *__current_framework; // 当前拥有屏幕控制权的框架
|
||||||
|
static uint32_t scm_ui_max_id = 0;
|
||||||
|
static bool __scm_alloc_enabled = false; // 允许动态申请内存的标志位
|
||||||
|
static bool __scm_double_buffer_enabled = false; // 允许双缓冲的标志位
|
||||||
/**
|
/**
|
||||||
* @brief 创建新的帧缓冲区
|
* @brief 创建新的帧缓冲区
|
||||||
*
|
*
|
||||||
@ -35,7 +37,7 @@ static struct scm_buffer_info_t *__create_buffer(uint64_t type)
|
|||||||
|
|
||||||
struct scm_buffer_info_t *buf = (struct scm_buffer_info_t *)kmalloc(sizeof(struct scm_buffer_info_t), 0);
|
struct scm_buffer_info_t *buf = (struct scm_buffer_info_t *)kmalloc(sizeof(struct scm_buffer_info_t), 0);
|
||||||
if (buf == NULL)
|
if (buf == NULL)
|
||||||
return -ENOMEM;
|
return (void*)-ENOMEM;
|
||||||
memset(buf, 0, sizeof(struct scm_buffer_info_t));
|
memset(buf, 0, sizeof(struct scm_buffer_info_t));
|
||||||
buf->bit_depth = video_frame_buffer_info.bit_depth;
|
buf->bit_depth = video_frame_buffer_info.bit_depth;
|
||||||
buf->flags = SCM_BF_DB;
|
buf->flags = SCM_BF_DB;
|
||||||
@ -55,7 +57,7 @@ static struct scm_buffer_info_t *__create_buffer(uint64_t type)
|
|||||||
return buf;
|
return buf;
|
||||||
failed:;
|
failed:;
|
||||||
kfree(buf);
|
kfree(buf);
|
||||||
return -ENOMEM;
|
return (void*)-ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -86,9 +88,12 @@ void scm_init()
|
|||||||
{
|
{
|
||||||
list_init(&scm_framework_list);
|
list_init(&scm_framework_list);
|
||||||
spin_init(&scm_register_lock);
|
spin_init(&scm_register_lock);
|
||||||
|
spin_init(&scm_screen_own_lock);
|
||||||
|
io_mfence();
|
||||||
scm_ui_max_id = 0;
|
scm_ui_max_id = 0;
|
||||||
__scm_alloc_enabled = false; // 禁用动态申请内存
|
__scm_alloc_enabled = false; // 禁用动态申请内存
|
||||||
__scm_double_buffer_enabled = false; // 禁用双缓冲
|
__scm_double_buffer_enabled = false; // 禁用双缓冲
|
||||||
|
__current_framework = NULL;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @brief 检查ui框架结构体中的参数设置是否合法
|
* @brief 检查ui框架结构体中的参数设置是否合法
|
||||||
@ -102,7 +107,7 @@ static int __check_ui_param(const char *name, const uint8_t type, const struct s
|
|||||||
{
|
{
|
||||||
if (name == NULL)
|
if (name == NULL)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
if (type != SCM_FRAMWORK_TYPE_GUI || type != SCM_FRAMWORK_TYPE_TEXT)
|
if (!(type == SCM_FRAMWORK_TYPE_GUI || type == SCM_FRAMWORK_TYPE_TEXT))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
if (ops == NULL)
|
if (ops == NULL)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
@ -153,6 +158,8 @@ int scm_register_alloc(const char *name, const uint8_t type, struct scm_ui_frame
|
|||||||
// 调用ui框架的回调函数以安装ui框架,并将其激活
|
// 调用ui框架的回调函数以安装ui框架,并将其激活
|
||||||
ui->ui_ops->install(ui->buf);
|
ui->ui_ops->install(ui->buf);
|
||||||
ui->ui_ops->enable(NULL);
|
ui->ui_ops->enable(NULL);
|
||||||
|
if (__current_framework == NULL)
|
||||||
|
return scm_framework_enable(ui);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,11 +177,12 @@ int scm_register(struct scm_ui_framework_t *ui)
|
|||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
list_init(&ui->list);
|
list_init(&ui->list);
|
||||||
spin_lock(&video_frame_buffer_info);
|
spin_lock(&scm_register_lock);
|
||||||
ui->id = scm_ui_max_id++;
|
ui->id = scm_ui_max_id++;
|
||||||
spin_unlock(&video_frame_buffer_info);
|
spin_unlock(&scm_register_lock);
|
||||||
|
|
||||||
ui->buf = __create_buffer(ui->type);
|
ui->buf = __create_buffer(ui->type);
|
||||||
|
|
||||||
if ((uint64_t)(ui->buf) == (uint64_t)-ENOMEM)
|
if ((uint64_t)(ui->buf) == (uint64_t)-ENOMEM)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
@ -184,6 +192,10 @@ int scm_register(struct scm_ui_framework_t *ui)
|
|||||||
// 调用ui框架的回调函数以安装ui框架,并将其激活
|
// 调用ui框架的回调函数以安装ui框架,并将其激活
|
||||||
ui->ui_ops->install(ui->buf);
|
ui->ui_ops->install(ui->buf);
|
||||||
ui->ui_ops->enable(NULL);
|
ui->ui_ops->enable(NULL);
|
||||||
|
|
||||||
|
if (__current_framework == NULL)
|
||||||
|
return scm_framework_enable(ui);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -225,6 +237,8 @@ int scm_enable_alloc()
|
|||||||
*/
|
*/
|
||||||
int scm_enable_double_buffer()
|
int scm_enable_double_buffer()
|
||||||
{
|
{
|
||||||
|
if (__scm_double_buffer_enabled == true)
|
||||||
|
return 0;
|
||||||
__scm_double_buffer_enabled = true;
|
__scm_double_buffer_enabled = true;
|
||||||
if (list_empty(&scm_framework_list))
|
if (list_empty(&scm_framework_list))
|
||||||
return 0;
|
return 0;
|
||||||
@ -235,9 +249,11 @@ int scm_enable_double_buffer()
|
|||||||
{
|
{
|
||||||
if (ptr->buf == &video_frame_buffer_info)
|
if (ptr->buf == &video_frame_buffer_info)
|
||||||
{
|
{
|
||||||
|
uart_send_str(COM1, "##init double buffer##");
|
||||||
struct scm_buffer_info_t *buf = __create_buffer(SCM_BF_DB | SCM_BF_PIXEL);
|
struct scm_buffer_info_t *buf = __create_buffer(SCM_BF_DB | SCM_BF_PIXEL);
|
||||||
if ((uint64_t)(buf) == (uint64_t)-ENOMEM)
|
if ((uint64_t)(buf) == (uint64_t)-ENOMEM)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
uart_send_str(COM1, "##to change double buffer##");
|
||||||
if (ptr->ui_ops->change(buf) != 0)
|
if (ptr->ui_ops->change(buf) != 0)
|
||||||
{
|
{
|
||||||
__destroy_buffer(buf);
|
__destroy_buffer(buf);
|
||||||
@ -245,9 +261,11 @@ int scm_enable_double_buffer()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while (list_next(&ptr->list) != &scm_framework_list);
|
} while (list_next(&ptr->list) != &scm_framework_list);
|
||||||
|
// 设置定时刷新的对象
|
||||||
|
video_set_refresh_target(__current_framework->buf);
|
||||||
// 通知显示驱动,启动双缓冲
|
// 通知显示驱动,启动双缓冲
|
||||||
video_reinitialize(true);
|
video_reinitialize(true);
|
||||||
|
uart_send_str(COM1, "##initialized double buffer##");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -261,8 +279,41 @@ int scm_framework_enable(struct scm_ui_framework_t *ui)
|
|||||||
{
|
{
|
||||||
if (ui->buf->vaddr == NULL)
|
if (ui->buf->vaddr == NULL)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
spin_lock(&scm_screen_own_lock);
|
||||||
|
int retval = 0;
|
||||||
|
if (__scm_double_buffer_enabled == true)
|
||||||
|
{
|
||||||
|
|
||||||
return video_set_refresh_target(ui->buf);
|
retval = video_set_refresh_target(ui->buf);
|
||||||
|
if (retval == 0)
|
||||||
|
__current_framework = ui;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
__current_framework = ui;
|
||||||
|
|
||||||
|
spin_unlock(&scm_screen_own_lock);
|
||||||
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 当内存管理单元被初始化之后,重新处理帧缓冲区问题
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void scm_reinit()
|
||||||
|
{
|
||||||
|
scm_enable_alloc();
|
||||||
|
video_reinitialize(false);
|
||||||
|
|
||||||
|
// 遍历当前所有使用帧缓冲区的框架,更新地址
|
||||||
|
// 逐个检查已经注册了的ui框架,将其缓冲区更改为双缓冲
|
||||||
|
struct scm_ui_framework_t *ptr = container_of(list_next(&scm_framework_list), struct scm_ui_framework_t, list);
|
||||||
|
do
|
||||||
|
{
|
||||||
|
if (ptr->buf == &video_frame_buffer_info)
|
||||||
|
{
|
||||||
|
ptr->ui_ops->change(&video_frame_buffer_info);
|
||||||
|
}
|
||||||
|
} while (list_next(&ptr->list) != &scm_framework_list);
|
||||||
|
return;
|
||||||
|
}
|
||||||
#pragma GCC pop_options
|
#pragma GCC pop_options
|
@ -33,11 +33,11 @@ struct scm_buffer_info_t
|
|||||||
*/
|
*/
|
||||||
struct scm_ui_framework_operations_t
|
struct scm_ui_framework_operations_t
|
||||||
{
|
{
|
||||||
int (*install)(struct scm_buffer_info_t *buf);
|
int (*install)(struct scm_buffer_info_t *buf); // 安装ui框架的回调函数
|
||||||
int (*uninstall)(void *args);
|
int (*uninstall)(void *args); // 卸载ui框架的回调函数
|
||||||
int (*enable)(void *args);
|
int (*enable)(void *args); // 启用ui框架的回调函数
|
||||||
int (*disable)(void *args);
|
int (*disable)(void *args); // 禁用ui框架的回调函数
|
||||||
int (*change)(struct scm_buffer_info_t *buf);
|
int (*change)(struct scm_buffer_info_t *buf); // 改变ui框架的帧缓冲区的回调函数
|
||||||
};
|
};
|
||||||
struct scm_ui_framework_t
|
struct scm_ui_framework_t
|
||||||
{
|
{
|
||||||
@ -47,7 +47,7 @@ struct scm_ui_framework_t
|
|||||||
uint8_t type;
|
uint8_t type;
|
||||||
struct scm_ui_framework_operations_t *ui_ops;
|
struct scm_ui_framework_operations_t *ui_ops;
|
||||||
struct scm_buffer_info_t *buf;
|
struct scm_buffer_info_t *buf;
|
||||||
}__attribute__((aligned(sizeof(uint64_t))));
|
} __attribute__((aligned(sizeof(uint64_t))));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 初始化屏幕管理模块
|
* @brief 初始化屏幕管理模块
|
||||||
@ -55,6 +55,12 @@ struct scm_ui_framework_t
|
|||||||
*/
|
*/
|
||||||
void scm_init();
|
void scm_init();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 当内存管理单元被初始化之后,重新处理帧缓冲区问题
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void scm_reinit();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 向屏幕管理器注册UI框架(动态获取框架对象结构体)
|
* @brief 向屏幕管理器注册UI框架(动态获取框架对象结构体)
|
||||||
*
|
*
|
||||||
@ -63,7 +69,7 @@ void scm_init();
|
|||||||
* @param ops 框架操作方法
|
* @param ops 框架操作方法
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
int scm_register_alloc(const char* name, const uint8_t type, struct scm_ui_framework_operations_t * ops);
|
int scm_register_alloc(const char *name, const uint8_t type, struct scm_ui_framework_operations_t *ops);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 向屏幕管理器注册UI框架(静态设置的框架对象)
|
* @brief 向屏幕管理器注册UI框架(静态设置的框架对象)
|
||||||
@ -71,7 +77,7 @@ int scm_register_alloc(const char* name, const uint8_t type, struct scm_ui_frame
|
|||||||
* @param ui 框架结构体指针
|
* @param ui 框架结构体指针
|
||||||
* @return int 错误码
|
* @return int 错误码
|
||||||
*/
|
*/
|
||||||
int scm_register(struct scm_ui_framework_t*ui);
|
int scm_register(struct scm_ui_framework_t *ui);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 向屏幕管理器卸载UI框架
|
* @brief 向屏幕管理器卸载UI框架
|
||||||
@ -79,7 +85,7 @@ int scm_register(struct scm_ui_framework_t*ui);
|
|||||||
* @param ui ui框架结构体
|
* @param ui ui框架结构体
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
int scm_unregister(struct scm_ui_framework_t*ui);
|
int scm_unregister(struct scm_ui_framework_t *ui);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 向屏幕管理器卸载动态创建的UI框架
|
* @brief 向屏幕管理器卸载动态创建的UI框架
|
||||||
@ -87,7 +93,7 @@ int scm_unregister(struct scm_ui_framework_t*ui);
|
|||||||
* @param ui ui框架结构体
|
* @param ui ui框架结构体
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
int scm_unregister_alloc(struct scm_ui_framework_t*ui);
|
int scm_unregister_alloc(struct scm_ui_framework_t *ui);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 允许动态申请内存
|
* @brief 允许动态申请内存
|
||||||
@ -109,4 +115,4 @@ int scm_enable_double_buffer();
|
|||||||
* @param ui 要启动的ui框架
|
* @param ui 要启动的ui框架
|
||||||
* @return int 返回码
|
* @return int 返回码
|
||||||
*/
|
*/
|
||||||
int scm_framework_enable(struct scm_ui_framework_t*ui);
|
int scm_framework_enable(struct scm_ui_framework_t *ui);
|
68
kernel/lib/libUI/textui.c
Normal file
68
kernel/lib/libUI/textui.c
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
#include "textui.h"
|
||||||
|
|
||||||
|
#include "screen_manager.h"
|
||||||
|
#include "driver/uart/uart.h"
|
||||||
|
#include <common/string.h>
|
||||||
|
#include <common/printk.h>
|
||||||
|
|
||||||
|
struct scm_ui_framework_t textui_framework;
|
||||||
|
|
||||||
|
int textui_install_handler(struct scm_buffer_info_t *buf)
|
||||||
|
{
|
||||||
|
return printk_init(buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
int textui_uninstall_handler(void *args)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
int textui_enable_handler(void *args)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
int textui_disable_handler(void *args)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
int textui_change_handler(struct scm_buffer_info_t *buf)
|
||||||
|
{
|
||||||
|
memcpy((void*)buf->vaddr, (void*)(textui_framework.buf->vaddr), textui_framework.buf->size);
|
||||||
|
textui_framework.buf = buf;
|
||||||
|
set_pos_VBE_FB_addr((uint*)buf->vaddr);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct scm_ui_framework_operations_t textui_ops =
|
||||||
|
{
|
||||||
|
.install = &textui_install_handler,
|
||||||
|
.uninstall = &textui_uninstall_handler,
|
||||||
|
.change = &textui_change_handler,
|
||||||
|
.enable = &textui_enable_handler,
|
||||||
|
.disable = &textui_disable_handler,
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 初始化text ui框架
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
int textui_init()
|
||||||
|
{
|
||||||
|
memset(&textui_framework, 0, sizeof(textui_framework));
|
||||||
|
io_mfence();
|
||||||
|
char name[] = "textUI";
|
||||||
|
strcpy(textui_framework.name, name);
|
||||||
|
|
||||||
|
textui_framework.ui_ops = &textui_ops;
|
||||||
|
textui_framework.type = SCM_FRAMWORK_TYPE_TEXT;
|
||||||
|
uart_send_str(COM1, "12121");
|
||||||
|
int retval = scm_register(&textui_framework);
|
||||||
|
if (retval != 0)
|
||||||
|
{
|
||||||
|
uart_send_str(COM1, "text ui init failed");
|
||||||
|
while (1)
|
||||||
|
pause();
|
||||||
|
}
|
||||||
|
uart_send_str(COM1, "text ui initialized");
|
||||||
|
return 0;
|
||||||
|
}
|
8
kernel/lib/libUI/textui.h
Normal file
8
kernel/lib/libUI/textui.h
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 初始化text ui框架
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
int textui_init();
|
@ -10,6 +10,7 @@
|
|||||||
#include "exception/irq.h"
|
#include "exception/irq.h"
|
||||||
#include <exception/softirq.h>
|
#include <exception/softirq.h>
|
||||||
#include <lib/libUI/screen_manager.h>
|
#include <lib/libUI/screen_manager.h>
|
||||||
|
#include <lib/libUI/textui.h>
|
||||||
#include "mm/mm.h"
|
#include "mm/mm.h"
|
||||||
#include "mm/slab.h"
|
#include "mm/slab.h"
|
||||||
#include "process/process.h"
|
#include "process/process.h"
|
||||||
@ -73,14 +74,11 @@ void system_initialize()
|
|||||||
uart_init(COM1, 115200);
|
uart_init(COM1, 115200);
|
||||||
video_init();
|
video_init();
|
||||||
|
|
||||||
// scm_init();
|
scm_init();
|
||||||
// 初始化printk
|
textui_init();
|
||||||
printk_init(8, 16);
|
|
||||||
//#ifdef DEBUG
|
|
||||||
//#endif
|
|
||||||
kinfo("Kernel Starting...");
|
kinfo("Kernel Starting...");
|
||||||
while (1)
|
|
||||||
pause();
|
|
||||||
// 重新加载gdt和idt
|
// 重新加载gdt和idt
|
||||||
|
|
||||||
ul tss_item_addr = (ul)phys_2_virt(0x7c00);
|
ul tss_item_addr = (ul)phys_2_virt(0x7c00);
|
||||||
@ -106,7 +104,7 @@ void system_initialize()
|
|||||||
// 原因是,系统启动初期,framebuffer被映射到48M地址处,
|
// 原因是,系统启动初期,framebuffer被映射到48M地址处,
|
||||||
// mm初始化完毕后,若不重新初始化显示驱动,将会导致错误的数据写入内存,从而造成其他模块崩溃
|
// mm初始化完毕后,若不重新初始化显示驱动,将会导致错误的数据写入内存,从而造成其他模块崩溃
|
||||||
// 对显示模块进行低级初始化,不启用double buffer
|
// 对显示模块进行低级初始化,不启用double buffer
|
||||||
video_reinitialize(false);
|
scm_reinit();
|
||||||
|
|
||||||
|
|
||||||
// =========== 重新设置initial_tss[0]的ist
|
// =========== 重新设置initial_tss[0]的ist
|
||||||
@ -165,8 +163,9 @@ void system_initialize()
|
|||||||
// kdebug("cpu_get_core_crysral_freq()=%ld", cpu_get_core_crysral_freq());
|
// kdebug("cpu_get_core_crysral_freq()=%ld", cpu_get_core_crysral_freq());
|
||||||
|
|
||||||
process_init();
|
process_init();
|
||||||
// 对显示模块进行高级初始化,启用double buffer
|
// 启用double buffer
|
||||||
video_reinitialize(true);
|
scm_enable_double_buffer();
|
||||||
|
|
||||||
io_mfence();
|
io_mfence();
|
||||||
|
|
||||||
// fat32_init();
|
// fat32_init();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user