🆕 完成了printk(暂不支持浮点数打印)

This commit is contained in:
fslongjin
2022-01-23 23:17:52 +08:00
parent ebb5ef2141
commit ead838bffd
8 changed files with 443 additions and 137 deletions

View File

@ -1,41 +1,70 @@
//
// Created by longjin on 2022/1/20.
//
int *address = (int *)0xffff800000a00000; //帧缓存区的地址
void show_color_band(int width, int height, char a, char b, char c, char d)
#include "common/glib.h"
#include "common/printk.h"
int *FR_address = (int *)0xffff800000a00000; //帧缓存区的地址
void show_welcome()
{
/** 向帧缓冲区写入像素值
* @param address: 帧缓存区的地址
* @param val:像素值
/**
* @brief 打印欢迎页面
*
*/
for (int i = 0; i < width * height; ++i)
{
*((char *)address + 0) = d;
*((char *)address + 1) = c;
*((char *)address + 2) = b;
*((char *)address + 3) = a;
++address;
}
printk("\n\n");
for (int i = 0; i < 74; ++i)
printk(" ");
printk_color(0x00e0ebeb, 0x00e0ebeb, " \n");
for (int i = 0; i < 74; ++i)
printk(" ");
printk_color(BLACK, 0x00e0ebeb, " Welcome to DragonOS ! \n");
for (int i = 0; i < 74; ++i)
printk(" ");
printk_color(0x00e0ebeb, 0x00e0ebeb, " \n");
}
void test_printk()
{
//测试直接输出
printk("\nTesting printk...\n");
//测试输出单个字符
printk("%c\n", 't');
//测试输出字符串%s
printk("%s\n", "xxx");
//测试输出数字
printk("%d %ld %lld\n", 1, 2, 3);
//测试输出两个百分号
printk("%%\n");
//测试输出\t
printk("\nTesting tab...\n");
printk("date\t\tname\tscore\n");
printk("2022-01-01\tDavid\t99\n");
printk("2022-01-01\tJohn\t95\n");
//测试输出八进制
printk("\nTest base 8 : %d --> %o\n", 255, 255);
//测试输出十六进制
printk("\nTest base 16 : %d --> %x\n", 255, 255);
printk("\nTest base 16 : %d --> %X\n", 255, 255);
}
//操作系统内核从这里开始执行
void Start_Kernel(void)
{
// 初始化printk
init_printk(1440, 900, FR_address, 1440 * 900 * 4, 8, 16);
show_welcome();
test_printk();
show_color_band(1440, 20, 0x00, 0xff, 0x00, 0x00);
show_color_band(1440, 20, 0x00, 0x00, 0xff, 0x00);
show_color_band(1440, 20, 0x00, 0x00, 0x00, 0xff);
show_color_band(1440, 20, 0x00, 0xff, 0xff, 0xff);
while (1)
;
}