mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-10 03:56:49 +00:00
🆕 实现简单的读取键盘数据的功能
This commit is contained in:
parent
8ab02c496c
commit
39ddc21ca5
@ -346,20 +346,19 @@ static int vsprintf(char *buf, const char *fmt, va_list args)
|
|||||||
if (qualifier == 'l')
|
if (qualifier == 'l')
|
||||||
ip = va_arg(args, long long *);
|
ip = va_arg(args, long long *);
|
||||||
else
|
else
|
||||||
ip = (ll*)va_arg(args, int *);
|
ip = (ll *)va_arg(args, int *);
|
||||||
|
|
||||||
*ip = str - buf;
|
*ip = str - buf;
|
||||||
break;
|
break;
|
||||||
case 'f':
|
case 'f':
|
||||||
// 默认精度为3
|
// 默认精度为3
|
||||||
//printk("1111\n");
|
//printk("1111\n");
|
||||||
//va_arg(args, double);
|
//va_arg(args, double);
|
||||||
//printk("222\n");
|
//printk("222\n");
|
||||||
|
|
||||||
if (precision < 0)
|
if (precision < 0)
|
||||||
precision = 3;
|
precision = 3;
|
||||||
str = write_float_point_num(str, va_arg(args, double), field_width, precision, flags);
|
str = write_float_point_num(str, va_arg(args, double), field_width, precision, flags);
|
||||||
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -402,12 +401,11 @@ static char *write_num(char *str, ull num, int base, int field_width, int precis
|
|||||||
if (flags & SMALL)
|
if (flags & SMALL)
|
||||||
digits = "0123456789abcdefghijklmnopqrstuvwxyz";
|
digits = "0123456789abcdefghijklmnopqrstuvwxyz";
|
||||||
|
|
||||||
if(flags&LEFT)
|
if (flags & LEFT)
|
||||||
flags &= ~PAD_ZERO;
|
flags &= ~PAD_ZERO;
|
||||||
// 设置填充元素
|
// 设置填充元素
|
||||||
pad = (flags & PAD_ZERO) ? '0' : ' ';
|
pad = (flags & PAD_ZERO) ? '0' : ' ';
|
||||||
|
|
||||||
|
|
||||||
sign = 0;
|
sign = 0;
|
||||||
if (flags & SIGN && num < 0)
|
if (flags & SIGN && num < 0)
|
||||||
{
|
{
|
||||||
@ -451,7 +449,7 @@ static char *write_num(char *str, ull num, int base, int field_width, int precis
|
|||||||
field_width -= precision;
|
field_width -= precision;
|
||||||
|
|
||||||
// 靠右对齐
|
// 靠右对齐
|
||||||
if (!(flags & (LEFT+PAD_ZERO)))
|
if (!(flags & (LEFT + PAD_ZERO)))
|
||||||
while (field_width-- > 0)
|
while (field_width-- > 0)
|
||||||
*str++ = ' ';
|
*str++ = ' ';
|
||||||
|
|
||||||
@ -465,8 +463,8 @@ static char *write_num(char *str, ull num, int base, int field_width, int precis
|
|||||||
}
|
}
|
||||||
else if (base == 8)
|
else if (base == 8)
|
||||||
*str++ = digits[24]; //注意这里是英文字母O或者o
|
*str++ = digits[24]; //注意这里是英文字母O或者o
|
||||||
if(!(flags&LEFT))
|
if (!(flags & LEFT))
|
||||||
while(field_width-->0)
|
while (field_width-- > 0)
|
||||||
*str++ = pad;
|
*str++ = pad;
|
||||||
while (js_num < precision)
|
while (js_num < precision)
|
||||||
{
|
{
|
||||||
|
@ -126,6 +126,20 @@ void init_irq()
|
|||||||
*/
|
*/
|
||||||
void do_IRQ(ul rsp, ul number)
|
void do_IRQ(ul rsp, ul number)
|
||||||
{
|
{
|
||||||
|
unsigned char x;
|
||||||
|
switch (number)
|
||||||
|
{
|
||||||
|
case 0x20: // 时钟中断信号
|
||||||
|
|
||||||
|
break;
|
||||||
|
case 0x21: // 键盘中断
|
||||||
|
|
||||||
|
x = io_in8(0x60);
|
||||||
|
printk_color(ORANGE, BLACK, "Received key irq, key code:%#018lx\n", x);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
if(number!=0x20)
|
if(number!=0x20)
|
||||||
printk_color(ORANGE, BLACK, "Received irq:%#018x\n", number);
|
printk_color(ORANGE, BLACK, "Received irq:%#018x\n", number);
|
||||||
|
|
||||||
|
@ -116,7 +116,6 @@ void Start_Kernel(void)
|
|||||||
test_mm();
|
test_mm();
|
||||||
|
|
||||||
//test_printk();
|
//test_printk();
|
||||||
|
|
||||||
//int t = 1 / 0; // 测试异常处理模块能否正常工作 触发除法错误
|
//int t = 1 / 0; // 测试异常处理模块能否正常工作 触发除法错误
|
||||||
// int t = *(int *)0xffff80000aa00000; // 触发页故障
|
// int t = *(int *)0xffff80000aa00000; // 触发页故障
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user