add gb2312 support!!! fuck u mingxuan
This commit is contained in:
parent
9d9f4000a7
commit
244df112bc
@ -41,6 +41,7 @@ void simpleconsole_write(char* buf, int nr);
|
||||
void simpleconsole_transfer(void (*write)(char ch));
|
||||
void simpleconsole_setcur(int row, int col);
|
||||
void fbcon_tty_write(NTTY* tty, char ch) ;
|
||||
void fbcon_screen_setup();
|
||||
|
||||
#define CON_MAX_LOGBUF 1024
|
||||
|
||||
|
||||
@ -11,7 +11,8 @@
|
||||
#pragma once
|
||||
#include "protect.h"
|
||||
#include "proc.h"
|
||||
|
||||
#include "const.h"
|
||||
#define USE_FBCON
|
||||
extern int kernel_initial;
|
||||
|
||||
extern int ticks;
|
||||
|
||||
@ -1,7 +1,10 @@
|
||||
#include "global.h"
|
||||
|
||||
#ifdef USE_FBCON
|
||||
|
||||
#include "bga.h"
|
||||
#include "console.h"
|
||||
#include "const.h"
|
||||
#include "global.h"
|
||||
#include "keyboard.h"
|
||||
#include "memman.h"
|
||||
#include "proc.h"
|
||||
@ -15,6 +18,8 @@
|
||||
#include "type.h"
|
||||
#include "x86.h"
|
||||
#include "yieldlock.h"
|
||||
#include "fs.h" //added by mingxuan 2019-5-19
|
||||
#include "vfs.h"
|
||||
|
||||
static int cur_col = 0;
|
||||
static int cur_row = 0;
|
||||
@ -33,13 +38,15 @@ static uintptr_t _fb_paddr = 0;
|
||||
static uint32_t* _fb = NULL;
|
||||
static uint32_t* cur_fb = NULL;
|
||||
static volatile int framecnt = 0;
|
||||
static char* textbuf;
|
||||
static u16* textbuf;
|
||||
char* hzk16h_buf;
|
||||
volatile u32 buflock;
|
||||
static int halfchar;
|
||||
|
||||
#define UNIT_CHAR_H (_fnt_char_height * _fbscale)
|
||||
#define UNIT_CHAR_W (_fnt_char_width * _fbscale)
|
||||
#define INDEX(row, col, mx) ((row) * (mx) + (col))
|
||||
|
||||
#define HZK16_SIZE (261696)
|
||||
#include "font8x8.h"
|
||||
static void fast_copy(void* dst, void* src, int len);
|
||||
|
||||
@ -57,6 +64,26 @@ static void fbcon_draw_raw(int row, int col, char ch) {
|
||||
}
|
||||
}
|
||||
|
||||
static void fbcon_draw_hzk(int row, int col, u16 ch) {
|
||||
u8 code0 = ((ch >> 8) & 0xff);
|
||||
u8 code1 = (ch & 0xff);
|
||||
if (code0 == 0) {fbcon_draw_raw(row, col, code1); return; }
|
||||
else { code0 -= 0xa0; code1 -= 0xa0; }
|
||||
u32 offset = (94 * (code0 - 1) + (code1 - 1)) * 32;
|
||||
u16* hzk16h = (u16*)&hzk16h_buf[offset];
|
||||
for (int x = 0; x < UNIT_CHAR_H; x++) {
|
||||
for (int y = 0; y < UNIT_CHAR_W; y++) {
|
||||
uint32_t ind = (col * UNIT_CHAR_W + (UNIT_CHAR_W - x)) + ((row * UNIT_CHAR_H + y) * _fbpixels_per_row);
|
||||
uint32_t clr = _basecolor;
|
||||
u16 bigend = (hzk16h[y] >> 8) | ((hzk16h[y] & 0xff) << 8);
|
||||
if (bigend & (1 << (x))) {
|
||||
clr ^= 0xffffffff;
|
||||
}
|
||||
cur_fb[ind] = clr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void draw_cursor() {
|
||||
fbcon_draw_raw(cur_row, cur_col, 0);
|
||||
}
|
||||
@ -66,7 +93,7 @@ static void draw_cursor_clear() {
|
||||
}
|
||||
|
||||
static void fbcon_scroll() {
|
||||
int lineoffset = _fbwidth * _fnt_char_height * _fbscale;
|
||||
int lineoffset = _fbwidth * _fnt_char_height * _fbscale * sizeof(*textbuf);
|
||||
fast_copy( (void*)cur_fb,
|
||||
(void*)cur_fb + lineoffset,
|
||||
_fbbufsize - lineoffset);
|
||||
@ -74,11 +101,18 @@ static void fbcon_scroll() {
|
||||
}
|
||||
|
||||
static void textbuf_scroll() {
|
||||
memcpy((void*) textbuf, (void*)textbuf + _scr_max_cols, (_scr_max_rows-1)*_scr_max_cols);
|
||||
memset((void*)textbuf + (_scr_max_rows-1)*_scr_max_cols, ' ', _scr_max_cols);
|
||||
memcpy((void*) textbuf, (void*)textbuf + _scr_max_cols *2, (_scr_max_rows-1)*_scr_max_cols * 2);
|
||||
memset((void*)textbuf + (_scr_max_rows-1)*_scr_max_cols*2, ' ', _scr_max_cols*2);
|
||||
}
|
||||
|
||||
static void fbcon_putchar(char ch) {
|
||||
static void fbcon_putchar(u8 ch) {
|
||||
if (ch >= 0xa0) {
|
||||
if (halfchar == 0) {
|
||||
textbuf[INDEX(cur_row, cur_col, _scr_max_cols)] = ch << 8;
|
||||
halfchar = 1;
|
||||
return;
|
||||
}
|
||||
}
|
||||
switch (ch)
|
||||
{
|
||||
case '\n':
|
||||
@ -102,7 +136,13 @@ static void fbcon_putchar(char ch) {
|
||||
}
|
||||
break;
|
||||
default:
|
||||
textbuf[INDEX(cur_row, cur_col, _scr_max_cols)] = ch;
|
||||
if (halfchar) {
|
||||
halfchar = 0;
|
||||
textbuf[INDEX(cur_row, cur_col, _scr_max_cols)] |= ch;
|
||||
}
|
||||
else {
|
||||
textbuf[INDEX(cur_row, cur_col, _scr_max_cols)] = ch;
|
||||
}
|
||||
cur_col ++;
|
||||
if (cur_col >= _scr_max_cols) {
|
||||
cur_col = 0;
|
||||
@ -117,7 +157,13 @@ static void fbcon_putchar(char ch) {
|
||||
}
|
||||
}
|
||||
|
||||
int screen_setup() {
|
||||
static void fbcon_clear_screen() {
|
||||
for (int i = 0; i < _scr_max_cols * _scr_max_rows; ++ i) {
|
||||
textbuf[i] = ' ';
|
||||
}
|
||||
}
|
||||
|
||||
void fbcon_screen_setup() {
|
||||
cur_col = 0;
|
||||
cur_row = 0;
|
||||
_fnt_char_width = 8;
|
||||
@ -132,14 +178,17 @@ int screen_setup() {
|
||||
cur_fb = _fb;
|
||||
_scr_max_cols = _fbwidth / _fnt_char_width / _fbscale;
|
||||
_scr_max_rows = _fbheight / _fnt_char_height / _fbscale;
|
||||
kprintf("bufsz = %p, maxsize(%d, %d)\n", _fbbufsize, _scr_max_rows, _scr_max_cols);
|
||||
|
||||
_basecolor = 0;
|
||||
cursor_blink = 1;
|
||||
framecnt = 0;
|
||||
textbuf = (char*)malloc(_scr_max_cols * _scr_max_rows);
|
||||
memset(textbuf, ' ', _scr_max_cols * _scr_max_rows);
|
||||
return 0;
|
||||
kprintf("allocating screen res...\n");
|
||||
textbuf = (u16*)K_PHY2LIN(sys_kmalloc(_scr_max_cols * _scr_max_rows * sizeof(*textbuf))); // alloc double for later use
|
||||
fbcon_clear_screen();
|
||||
// memset(textbuf, ' ', _scr_max_cols * _scr_max_rows);
|
||||
hzk16h_buf = (char*)K_PHY2LIN(sys_kmalloc(HZK16_SIZE));
|
||||
halfchar = 0;
|
||||
// kprintf("bufsz = %p, maxsize(%d, %d) textbuf=%p, fontbuf=%p\n", _fbbufsize, _scr_max_rows, _scr_max_cols, textbuf, hzk16h_buf);
|
||||
}
|
||||
|
||||
|
||||
@ -187,16 +236,25 @@ static void fast_copy(void* dst, void* src, int len) {
|
||||
static void textbuf_render() {
|
||||
for (int row = 0; row < _scr_max_rows; ++ row) {
|
||||
for (int col = 0; col < _scr_max_cols; ++ col) {
|
||||
fbcon_draw_raw(row, col, textbuf[INDEX(row, col, _scr_max_cols)]);
|
||||
fbcon_draw_hzk(row, col, textbuf[INDEX(row, col, _scr_max_cols)]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void fbcon_switchfont() {
|
||||
while (xchg(&buflock, 1) == 1)
|
||||
yield();
|
||||
_fbscale = 1;
|
||||
xchg(&buflock, 0);
|
||||
}
|
||||
|
||||
#endif
|
||||
void task_tty() {
|
||||
#ifdef USE_FBCON
|
||||
// main rountine for drawing framebuffered console
|
||||
screen_setup();
|
||||
mmap((u32)_fb, _fb_paddr, _fbwidth * _fbheight * 4 * 2);
|
||||
buflock = 0;
|
||||
|
||||
// fbcon_write(text1, strlen(text1));
|
||||
int cur_buf = 0, last_buf = 1;
|
||||
while (1) {
|
||||
@ -216,4 +274,7 @@ void task_tty() {
|
||||
|
||||
sleep(5); // to no need to refresh that fast
|
||||
}
|
||||
#else
|
||||
while(1) yield();
|
||||
#endif
|
||||
}
|
||||
@ -13,6 +13,7 @@
|
||||
#include "fs.h"
|
||||
#include "vfs.h"
|
||||
#include "string.h"
|
||||
#include "stdio.h"
|
||||
|
||||
/**
|
||||
* @struct posix_tar_header
|
||||
@ -112,6 +113,8 @@ static void untar(const char *filename)
|
||||
|
||||
printf(" done, %d files extracted]\n", i);
|
||||
}
|
||||
extern char* hzk16h_buf;
|
||||
#define HZK16_SIZE (261696)
|
||||
|
||||
void initial()
|
||||
{
|
||||
@ -131,7 +134,18 @@ void initial()
|
||||
do_vclose(stdin);
|
||||
do_vclose(stdout);
|
||||
do_vclose(stderr);
|
||||
|
||||
kprintf("loading font(%dKB) to %p...", HZK16_SIZE / num_1K, hzk16h_buf);
|
||||
int fd = do_vopen("orange/hzk16h", O_RDWR);
|
||||
do_vlseek(fd, 0, SEEK_SET);
|
||||
for (int i = 0; i < HZK16_SIZE/64; ++ i)
|
||||
{
|
||||
do_vread(fd, hzk16h_buf + i * 64, 64);
|
||||
if (i % 50 == 0) kprintf(".");
|
||||
}
|
||||
if (hzk16h_buf[0x54] != 0x30) kprintf("!!!\n");
|
||||
do_vclose(fd);
|
||||
kprintf("[\x1b[32mOK\x1b[0m]\n");
|
||||
// while(untared) yield();
|
||||
exec("orange/shell_0.bin");
|
||||
|
||||
while (1)
|
||||
|
||||
@ -45,9 +45,6 @@ int kernel_main()
|
||||
|
||||
init(); // 内存管理模块的初始化 add by liang
|
||||
init_tty_main();
|
||||
init_pci();
|
||||
pci_dev_t* dev_bga = get_pci_bga();
|
||||
init_bga(dev_bga);
|
||||
|
||||
// initialize PCBs, added by xw, 18/5/26
|
||||
error = initialize_processes();
|
||||
@ -101,7 +98,12 @@ int kernel_main()
|
||||
init_fs();
|
||||
init_fs_fat(); // added by mingxuan 2019-5-17
|
||||
// init_vfs(); //added by mingxuan 2019-5-17 //deleted by mingxuan 2020-10-30
|
||||
|
||||
#ifdef USE_FBCON
|
||||
init_pci();
|
||||
pci_dev_t* dev_bga = get_pci_bga();
|
||||
init_bga(dev_bga);
|
||||
fbcon_screen_setup();
|
||||
#endif
|
||||
/*************************************************************************
|
||||
*第一个进程开始启动执行
|
||||
**************************************************************************/
|
||||
|
||||
@ -27,7 +27,7 @@
|
||||
}
|
||||
}
|
||||
p_proc_next = p_proc_current;
|
||||
kprintf("shit\n");
|
||||
// kprintf("shit\n");
|
||||
|
||||
// int greatest_ticks = 0;
|
||||
// //Added by xw, 18/4/21
|
||||
|
||||
18
kernel/tty.c
18
kernel/tty.c
@ -59,11 +59,9 @@ void init_tty_main()
|
||||
NTTY *tty;
|
||||
for (int i = 0; i < 1; ++i)
|
||||
{
|
||||
// tty = &ntty_table[i];
|
||||
tty = (NTTY*)K_PHY2LIN(do_kmalloc(sizeof(NTTY)));
|
||||
tty->driver_type = 1; // vga
|
||||
// tty->input_buf = (void*)do_kmalloc(sizeof(keyboard_buf));
|
||||
// tty->output_buf = (void*)do_kmalloc(sizeof(vga_buf));
|
||||
tty->driver_type = 1;
|
||||
#ifdef USE_FBCON
|
||||
tty->input_buf = (keyboard_buf*)K_PHY2LIN(do_kmalloc(sizeof(keyboard_buf)));
|
||||
tty->output_buf = NULL;
|
||||
// vga_tty_init(tty);
|
||||
@ -72,6 +70,18 @@ void init_tty_main()
|
||||
tty->read = ps2_tty_read;
|
||||
tty->recvbuf = ps2_tty_recvbuf;
|
||||
tty->ioctl = dummy_ioctl;
|
||||
#else
|
||||
tty = (NTTY*)K_PHY2LIN(do_kmalloc(sizeof(NTTY)));
|
||||
tty->driver_type = 1;
|
||||
tty->input_buf = (keyboard_buf*)K_PHY2LIN(do_kmalloc(sizeof(keyboard_buf)));
|
||||
tty->output_buf = (vga_buf*)K_PHY2LIN(do_kmalloc(sizeof(vga_buf)));
|
||||
vga_tty_init(tty);
|
||||
ps2_tty_init(tty);
|
||||
tty->write = vga_tty_write;
|
||||
tty->read = ps2_tty_read;
|
||||
tty->recvbuf = ps2_tty_recvbuf;
|
||||
tty->ioctl = ps2_vga_ioctl;
|
||||
#endif
|
||||
ntty_table[i] = tty;
|
||||
}
|
||||
for (int i = 1; i < 2; ++i)
|
||||
|
||||
@ -32,4 +32,5 @@ $(OBJDIR)/user/%.bin: $(OBJDIR)/user/%.o $(USERLIB_OBJS) $(LIB_A) $(OBJDIR)/.var
|
||||
|
||||
$(OBJDIR)/user/$(USER_TAR): $(USER_BINS)
|
||||
@echo + tar $@
|
||||
@tar -vcf $@ -C $(OBJDIR)/user $(USER_BASENAMES)
|
||||
@cp -f user/hzk16h $(OBJDIR)/user/
|
||||
@tar -vcf $@ -C $(OBJDIR)/user $(USER_BASENAMES) hzk16h
|
||||
BIN
user/hzk16h
Normal file
BIN
user/hzk16h
Normal file
Binary file not shown.
@ -16,9 +16,10 @@ int main(int arg, char *argv[])
|
||||
char buf[1024];
|
||||
int pid;
|
||||
int times = 0;
|
||||
printf("ÄãºÃ\n");
|
||||
while (1)
|
||||
{
|
||||
printf("\nminiOS:/ $ ");
|
||||
printf("\nÀ¬»øOS:/ $ ");
|
||||
if (gets(buf) && strlen(buf) != 0)
|
||||
{
|
||||
if (exec(buf) != 0)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user