mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-18 08:06:32 +00:00
🆕 重新初始化页表并重映射了VBE帧缓存区
This commit is contained in:
@ -8,6 +8,7 @@
|
||||
//#include "linkage.h"
|
||||
|
||||
struct screen_info pos;
|
||||
ul VBE_FB_phys_addr; // 由bootloader传来的帧缓存区的物理地址
|
||||
|
||||
int calculate_max_charNum(int len, int size)
|
||||
{
|
||||
@ -33,7 +34,8 @@ int printk_init(const int char_size_x, const int char_size_y)
|
||||
pos.max_y = calculate_max_charNum(pos.height, char_size_y);
|
||||
|
||||
// @todo:将来需要将帧缓冲区物理地址填写到这个地址的页表项中
|
||||
pos.FB_address = (unsigned int*)0x3000000;
|
||||
VBE_FB_phys_addr = (ul *)info.framebuffer_addr;
|
||||
pos.FB_address = (unsigned int *)0x0000000003000000;
|
||||
pos.FB_length = pos.width * pos.height;
|
||||
|
||||
pos.x = 0;
|
||||
@ -81,9 +83,9 @@ void auto_newline()
|
||||
if (pos.y > pos.max_y)
|
||||
{
|
||||
pos.y = pos.max_y;
|
||||
int lines_to_scroll=2;
|
||||
scroll(true, lines_to_scroll*pos.char_size_y, false);
|
||||
pos.y-=lines_to_scroll;
|
||||
int lines_to_scroll = 2;
|
||||
scroll(true, lines_to_scroll * pos.char_size_y, false);
|
||||
pos.y -= lines_to_scroll;
|
||||
}
|
||||
}
|
||||
|
||||
@ -690,8 +692,8 @@ int do_scroll(bool direction, int pixels)
|
||||
unsigned int src = pixels * pos.width;
|
||||
unsigned int count = pos.FB_length - src;
|
||||
|
||||
memcpy(pos.FB_address, (pos.FB_address + src), sizeof(unsigned int)*(pos.FB_length - src));
|
||||
memset(pos.FB_address+(pos.FB_length-src), 0, sizeof(unsigned int)*(src));
|
||||
memcpy(pos.FB_address, (pos.FB_address + src), sizeof(unsigned int) * (pos.FB_length - src));
|
||||
memset(pos.FB_address + (pos.FB_length - src), 0, sizeof(unsigned int) * (src));
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
@ -742,18 +744,17 @@ int scroll(bool direction, int pixels, bool animation)
|
||||
trace[js_trace] = (int)(accelerate * i + 0.5);
|
||||
current_pixels += trace[js_trace];
|
||||
do_scroll(direction, trace[js_trace]);
|
||||
|
||||
|
||||
++js_trace;
|
||||
}
|
||||
|
||||
|
||||
// 强制使得位置位于1/2*pixels
|
||||
if (current_pixels < pixels / 2)
|
||||
{
|
||||
delta_x = pixels / 2 - current_pixels;
|
||||
do_scroll(direction, delta_x);
|
||||
}
|
||||
|
||||
|
||||
// 减速阶段,是加速阶段的重放
|
||||
for (int i = js_trace - 1; i >= 0; --i)
|
||||
{
|
||||
@ -763,7 +764,7 @@ int scroll(bool direction, int pixels, bool animation)
|
||||
|
||||
if (current_pixels > pixels)
|
||||
kerror("During scrolling: scrolled pixels over bound!");
|
||||
|
||||
|
||||
// 强制使得位置位于pixels
|
||||
if (current_pixels < pixels)
|
||||
{
|
||||
@ -771,7 +772,7 @@ int scroll(bool direction, int pixels, bool animation)
|
||||
do_scroll(direction, delta_x);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -785,4 +786,30 @@ int cls()
|
||||
pos.x = 0;
|
||||
pos.y = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 获取VBE帧缓存区的物理地址
|
||||
*
|
||||
*/
|
||||
ul get_VBE_FB_phys_addr()
|
||||
{
|
||||
return VBE_FB_phys_addr;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 获取VBE帧缓冲区长度
|
||||
*/
|
||||
ul get_VBE_FB_length()
|
||||
{
|
||||
return pos.FB_length;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 设置pos变量中的VBE帧缓存区的线性地址
|
||||
* @param virt_addr VBE帧缓存区线性地址
|
||||
*/
|
||||
void set_pos_VBE_FB_addr(ul virt_addr)
|
||||
{
|
||||
pos.FB_address = virt_addr;
|
||||
}
|
@ -3,7 +3,6 @@
|
||||
//
|
||||
#pragma once
|
||||
|
||||
|
||||
#define PAD_ZERO 1 // 0填充
|
||||
#define LEFT 2 // 靠左对齐
|
||||
#define RIGHT 4 // 靠右对齐
|
||||
@ -47,31 +46,31 @@ struct screen_info
|
||||
int char_size_x, char_size_y;
|
||||
|
||||
unsigned int *FB_address; //帧缓冲区首地址
|
||||
unsigned long FB_length; // 帧缓冲区长度
|
||||
};
|
||||
|
||||
unsigned long FB_length; // 帧缓冲区长度
|
||||
};
|
||||
|
||||
extern unsigned char font_ascii[256][16]; //导出ascii字体的bitmap(8*16大小) ps:位于font.h中
|
||||
|
||||
char buf[4096]; //vsprintf()的缓冲区
|
||||
char buf[4096]; // vsprintf()的缓冲区
|
||||
|
||||
/**
|
||||
* @brief 初始化printk的屏幕信息
|
||||
*
|
||||
*
|
||||
* @param char_size_x 字符的列坐标
|
||||
* @param char_size_y 字符的行坐标
|
||||
*/
|
||||
int printk_init(const int char_size_x, const int char_size_y);
|
||||
/**
|
||||
* @brief Set the printk pos object
|
||||
*
|
||||
*
|
||||
* @param x 列坐标
|
||||
* @param y 行坐标
|
||||
*/
|
||||
int set_printk_pos(const int x, const int y);
|
||||
/**
|
||||
* @brief 将字符串按照fmt和args中的内容进行格式化,然后保存到buf中
|
||||
*
|
||||
*
|
||||
* @param buf 结果缓冲区
|
||||
* @param fmt 格式化字符串
|
||||
* @param args 内容
|
||||
@ -81,22 +80,21 @@ static int vsprintf(char *buf, const char *fmt, va_list args);
|
||||
|
||||
/**
|
||||
* @brief 将数字按照指定的要求转换成对应的字符串(2~36进制)
|
||||
*
|
||||
*
|
||||
* @param str 要返回的字符串
|
||||
* @param num 要打印的数值
|
||||
* @param base 基数
|
||||
* @param field_width 区域宽度
|
||||
* @param field_width 区域宽度
|
||||
* @param precision 精度
|
||||
* @param flags 标志位
|
||||
*/
|
||||
static char* write_num(char *str, ull num, int base, int field_width, int precision, int flags);
|
||||
|
||||
static char *write_num(char *str, ull num, int base, int field_width, int precision, int flags);
|
||||
|
||||
static char *write_float_point_num(char *str, double num, int field_width, int precision, int flags);
|
||||
|
||||
/**
|
||||
* @brief 在屏幕上指定位置打印字符
|
||||
*
|
||||
*
|
||||
* @param fb 帧缓存线性地址
|
||||
* @param Xsize 行分辨率
|
||||
* @param x 左上角列像素点位置
|
||||
@ -109,20 +107,19 @@ static void putchar(unsigned int *fb, int Xsize, int x, int y, unsigned int FRco
|
||||
|
||||
/**
|
||||
* @brief 格式化打印字符串
|
||||
*
|
||||
*
|
||||
* @param FRcolor 前景色
|
||||
* @param BKcolor 背景色
|
||||
* @param ... 格式化字符串
|
||||
*/
|
||||
|
||||
#define printk(...) printk_color(WHITE, BLACK, __VA_ARGS__)
|
||||
|
||||
#define printk(...) printk_color( WHITE, BLACK, __VA_ARGS__ )
|
||||
|
||||
int printk_color(unsigned int FRcolor, unsigned int BKcolor, const char*fmt, ...);
|
||||
int printk_color(unsigned int FRcolor, unsigned int BKcolor, const char *fmt, ...);
|
||||
|
||||
/**
|
||||
* @brief 滚动窗口(尚不支持向下滚动)
|
||||
*
|
||||
*
|
||||
* @param direction 方向,向上滑动为true,否则为false
|
||||
* @param pixels 要滑动的像素数量
|
||||
* @param animation 是否包含滑动动画
|
||||
@ -131,6 +128,24 @@ int scroll(bool direction, int pixels, bool animation);
|
||||
|
||||
/**
|
||||
* @brief 清屏
|
||||
*
|
||||
*/
|
||||
int cls();
|
||||
|
||||
/**
|
||||
* @brief 获取VBE帧缓存区的物理地址
|
||||
*
|
||||
*/
|
||||
int cls();
|
||||
ul get_VBE_FB_phys_addr();
|
||||
|
||||
/**
|
||||
* @brief 获取VBE帧缓冲区长度
|
||||
|
||||
*/
|
||||
ul get_VBE_FB_length();
|
||||
|
||||
/**
|
||||
* @brief 设置pos变量中的VBE帧缓存区的线性地址
|
||||
* @param virt_addr VBE帧缓存区线性地址
|
||||
*/
|
||||
void set_pos_VBE_FB_addr(ul virt_addr);
|
Reference in New Issue
Block a user