Chinaunix首页 | 论坛 | 博客
  • 博客访问: 704157
  • 博文数量: 60
  • 博客积分: 2849
  • 博客等级: 少校
  • 技术积分: 1011
  • 用 户 组: 普通用户
  • 注册时间: 2007-03-10 15:38
文章分类
文章存档

2013年(4)

2012年(11)

2011年(5)

2010年(3)

2009年(9)

2008年(19)

2007年(9)

分类:

2008-05-24 21:43:49

jinix是小弟正在实现的一个c++ kernel,因为调试缘故,所以早早的把控制台部分调出来了,以便于后来的调试。代码使用c++写的,如果使用c写内核也很容易移植过去。转载请保留原 创:http://jinglexy.cublog.cnmail & msn: jinglexy at yahoo dot com dot cn。这部分代码是在内存管理之前实现的,所以没有做到任意个数虚拟控制台(内核在编译时候确定个数),并且每个控制台显存地址固定起来了。如果要实现也 比较简单:启动时候初始化一个控制台,在MM初始化完后初始化其他控制台,每个控制台包含自己的显存缓冲区,切换控制台的时候将该缓冲区拷贝到显存中即 可。

文件:textio.h, textio.cpp, ostream.h, ostream.cpp
textio.h
源文件如下:


39: void move_cursor(void);
64:


这个文件完成显存的一些字符操作,及显存页面切换,滚屏也很简单。没有加入posix兼容的一些特性,
还没有想好是否加在这里。rs232也会使用终端特性,所以考虑后期将字符设备驱动抽象成一个基类,
作为textio类的父类。有什么好的想法可以和我讨论:http://www.cppblog.com/jinglexy

ostream.h
源文件:

38: int current_flags; /* 显示模式: 进制数, 对齐形式等 */
41: #define cout __vconsole[__cur_console]
49: extern int __cur_console;

32: void TextIO::move_cursor(void)
103: move_cursor();
201: move_cursor();
6: int __cur_console; /* 当前控制台 */
10: current_flags = dec;
41: if (current_flags & dec)
43: else if (current_flags & hex)
45: else if (current_flags & oct)
47: else if (current_flags & bin)
50: if (current_flags & hex && current_flags & showbase)
79: if (current_flags & dec)
81: else if (current_flags & hex)
83: else if (current_flags & oct)
85: else if (current_flags & bin)
88: if (current_flags & hex && current_flags & showbase)
103: current_flags = f;
111: /* set current console */
112: __cur_console = console;
117: /* move cursor */
118: cout.move_cursor();
127: /* set current console */
128: __cur_console = console;

阅读(1505) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~