delete disp_*

This commit is contained in:
xiaoxiao 2023-01-02 13:06:27 +08:00
parent f70a22b8c2
commit c40f00c80e
14 changed files with 362 additions and 566 deletions

View File

@ -57,8 +57,8 @@
/* 8253/8254 PIT (Programmable Interval Timer) */
#define TIMER0 0x40 /* I/O port for timer channel 0 */
#define TIMER_MODE 0x43 /* I/O port for timer mode control */
#define RATE_GENERATOR 0x34 /* 00-11-010-0 :
* Counter0 - LSB then MSB - rate generator - binary
#define RATE_GENERATOR 0x34 /* 00-11-010-0 : \
* Counter0 - LSB then MSB - rate generator - binary \
*/
#define TIMER_FREQ 1193182L /* clock frequency for timer in PC and AT */
#define HZ 100 /* clock freq (software settable on IBM-PC) */
@ -79,7 +79,7 @@
/* system call */
// #define NR_SYS_CALL 23 //last modified by xw, 18/6/19
#define NR_SYS_CALL 28 //modified by mingxuan 2019-5-17
#define NR_SYS_CALL 26 // modified by mingxuan 2019-5-17
/* TTY */
// added by mingxuan 2019-5-19
@ -136,15 +136,15 @@
/* AT keyboard */
/* 8042 ports */
// added by mingxuan 2019-5-19
#define KB_DATA 0x60 /* I/O port for keyboard data
* Read : Read Output Buffer
* Write: Write Input Buffer
* (8042 Data & 8048 Command)
#define KB_DATA 0x60 /* I/O port for keyboard data \
* Read : Read Output Buffer \
* Write: Write Input Buffer \
* (8042 Data & 8048 Command) \
*/
#define KB_CMD 0x64 /* I/O port for keyboard command
* Read : Read Status Register
* Write: Write Input Buffer
* (8042 Command)
#define KB_CMD 0x64 /* I/O port for keyboard command \
* Read : Read Status Register \
* Write: Write Input Buffer \
* (8042 Command) \
*/
#define KB_STA 0x64
#define KEYSTA_SEND_NOTREADY 0x02

View File

@ -5,12 +5,6 @@
Forrest Yu, 2005
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/* klib.asm */
void disp_str(char* info);
void disp_int(int input);
void disp_color_str(char* info, int color);
void write_char(char ch); //added by mingxuan 2019-5-19
// added by zcr
void disable_irq(int irq);
void enable_irq(int irq);
@ -82,8 +76,6 @@ int free(void *arg); //edit by visual 2016.5.9
int free_4k(void *AdddrLin); // edit by visual 2016.5.9
int fork(); // add by visual 2016.4.8
int pthread(void *arg); // add by visual 2016.4.11
void udisp_int(int arg); //add by visual 2016.5.16
void udisp_str(char* arg); //add by visual 2016.5.16
u32 exec(char *path); // add by visual 2016.5.16
void yield(); // added by xw, 18/4/19
void sleep(int n); // added by xw, 18/4/19
@ -100,8 +92,6 @@ void* sys_malloc_4k(); //edit by visual 2016.5.9
int sys_free(void *arg); // edit by visual 2016.5.9
int sys_free_4k(void *AdddrLin); // edit by visual 2016.5.9
int sys_pthread(void *arg); // add by visual 2016.4.11
void sys_udisp_int(int arg); //add by visual 2016.5.16
void sys_udisp_str(char* arg); //add by visual 2016.5.16
/* proc.c */
PROCESS *alloc_PCB();
@ -140,4 +130,3 @@ void write_page_pte( u32 TblPhyAddr,u32 AddrLin,u32 PhyAddr,u32 Attribute);
u32 vmalloc(u32 size);
int lin_mapping_phy(u32 AddrLin, u32 phy_addr, u32 pid, u32 pde_Attribute, u32 pte_Attribute); // edit by visual 2016.5.19
void clear_kernel_pagepte_low(); // add by visual 2016.5.12

View File

@ -19,8 +19,6 @@ int free(void *arg);
int free_4k(void *AdddrLin);
int fork();
int pthread(void *arg);
void udisp_int(int arg);
void udisp_str(char* arg);
// added by xw
/* file system */

View File

@ -33,7 +33,6 @@ KERN_SRCFILES :=kernel/kernel.asm \
kernel/serialport.c \
kernel/vga.c \
lib/klib.c \
lib/kliba.asm \
KERN_OBJFILES := $(patsubst %.c, $(OBJDIR)/%.o, $(KERN_SRCFILES))

View File

@ -97,7 +97,6 @@ void out_char(CONSOLE *con, char ch)
//*(pch - 2) = ' ';
//*(pch - 1) = DEFAULT_CHAR_COLOR;
disp_pos = con->cursor * 2;
// write_char(' ');
write_char_c(disp_pos, ' ');
}
break;
@ -105,7 +104,6 @@ void out_char(CONSOLE *con, char ch)
//*pch++ = ch;
//*pch++ = DEFAULT_CHAR_COLOR;
disp_pos = con->cursor * 2;
// write_char(ch);
write_char_c(disp_pos, ch);
con->cursor++;

View File

@ -61,19 +61,17 @@ system_call sys_call_table[NR_SYS_CALL] = {
sys_free_4k, // add by visual 2016.4.7
sys_fork, // add by visual 2016.4.8
sys_pthread, // add by visual 2016.4.11 //10th
sys_udisp_int, // add by visual 2016.5.16
sys_udisp_str, // add by visual 2016.5.16
sys_exec, // add by visual 2016.5.16
sys_yield, // added by xw
sys_sleep, // added by xw //15th
sys_sleep, // added by xw //13th
sys_print_E, // added by xw
sys_print_F, // added by xw
sys_open, // added by xw, 18/6/18
sys_close, // added by xw, 18/6/18
sys_read, // added by xw, 18/6/18 //20th
sys_read, // added by xw, 18/6/18 //18th
sys_write, // added by xw, 18/6/18
sys_lseek, // added by xw, 18/6/18
sys_unlink, // added by xw, 18/6/19 //23th
sys_unlink, // added by xw, 18/6/19 //21th
sys_create, // added by mingxuan 2019-5-17
sys_delete, // added by mingxuan 2019-5-17
sys_opendir, // added by mingxuan 2019-5-17

View File

@ -14,12 +14,10 @@ extern kernel_main
extern exception_handler
extern spurious_irq
extern clock_handler
extern disp_str
extern delay
extern irq_table
extern page_fault_handler
extern divide_error_handler ;added by xw, 18/12/22
extern disp_int
extern schedule
extern switch_pde

View File

@ -132,8 +132,7 @@ void initial()
do_vclose(stdout);
do_vclose(stderr);
// exec("orange/shell_1.bin");
exec("orange/test.bin");
exec("orange/shell_1.bin");
while (1)
;

View File

@ -37,12 +37,6 @@ int kernel_main()
init_serial();
int error;
// disp_pos = 0;
// for (int i = 0; i < 25; i++) {
// for (int j = 0; j < 80; j++) {
// disp_str(" ");
// }
// }
disp_pos = 0;
// kprintf("-----Kernel Initialization Begins-----\n");

View File

@ -17,26 +17,24 @@ _NR_free equ 6 ; //add by visual 2016.4.7
_NR_free_4k equ 7 ; //add by visual 2016.4.7
_NR_fork equ 8 ; //add by visual 2016.4.8
_NR_pthread equ 9 ; //add by visual 2016.4.11
_NR_udisp_int equ 10 ; //add by visual 2016.5.16
_NR_udisp_str equ 11 ; //add by visual 2016.5.16
_NR_exec equ 12 ; //add by visual 2016.5.16
_NR_yield equ 13 ; //added by xw, 17/12
_NR_sleep equ 14 ; //added by xw, 17/12
_NR_print_E equ 15 ; //added by xw, 18/4/27
_NR_print_F equ 16 ; //added by xw, 18/4/27
_NR_exec equ 10 ; //add by visual 2016.5.16
_NR_yield equ 11 ; //added by xw, 17/12
_NR_sleep equ 12 ; //added by xw, 17/12
_NR_print_E equ 13 ; //added by xw, 18/4/27
_NR_print_F equ 14 ; //added by xw, 18/4/27
_NR_open equ 17 ; //added by xw, 18/6/18
_NR_close equ 18 ; //added by xw, 18/6/18
_NR_read equ 19 ; //added by xw, 18/6/18
_NR_write equ 20 ; //added by xw, 18/6/18
_NR_lseek equ 21 ; //added by xw, 18/6/18
_NR_unlink equ 22 ; //added by xw, 18/6/18
_NR_open equ 15 ; //added by xw, 18/6/18
_NR_close equ 16 ; //added by xw, 18/6/18
_NR_read equ 17 ; //added by xw, 18/6/18
_NR_write equ 18 ; //added by xw, 18/6/18
_NR_lseek equ 19 ; //added by xw, 18/6/18
_NR_unlink equ 20 ; //added by xw, 18/6/18
_NR_create equ 23 ; //added by mingxuan 2019-5-17
_NR_delete equ 24 ; //added by mingxuan 2019-5-17
_NR_opendir equ 25 ; //added by mingxuan 2019-5-17
_NR_createdir equ 26 ; //added by mingxuan 2019-5-17
_NR_deletedir equ 27 ; //added by mingxuan 2019-5-17
_NR_create equ 21 ; //added by mingxuan 2019-5-17
_NR_delete equ 22 ; //added by mingxuan 2019-5-17
_NR_opendir equ 22 ; //added by mingxuan 2019-5-17
_NR_createdir equ 24 ; //added by mingxuan 2019-5-17
_NR_deletedir equ 25 ; //added by mingxuan 2019-5-17
INT_VECTOR_SYS_CALL equ 0x90
@ -51,8 +49,6 @@ global free ; //add by visual 2016.4.7
global free_4k ; //add by visual 2016.4.7
global fork ; //add by visual 2016.4.8
global pthread ; //add by visual 2016.4.11
global udisp_int ; //add by visual 2016.5.16
global udisp_str ; //add by visual 2016.5.16
global exec ; //add by visual 2016.5.16
global yield ; //added by xw
global sleep ; //added by xw
@ -175,27 +171,6 @@ pthread:
pop ebx
ret
; ====================================================================
; udisp_int //add by visual 2016.5.16
; ====================================================================
udisp_int:
push ebx
mov ebx,[esp+8]
mov eax, _NR_udisp_int
int INT_VECTOR_SYS_CALL
pop ebx
ret
; ====================================================================
; udisp_str //add by visual 2016.5.16
; ====================================================================
udisp_str:
push ebx
mov ebx,[esp+8]
mov eax, _NR_udisp_str
int INT_VECTOR_SYS_CALL
pop ebx
ret
; ====================================================================
; exec //add by visual 2016.5.16

View File

@ -24,7 +24,6 @@ int sys_get_ticks()
return ticks;
}
/*======================================================================*
sys_get_pid add by visual 2016.4.6
*======================================================================*/
@ -68,7 +67,6 @@ void* sys_malloc(int size)
return (void *)vir_addr;
}
/*======================================================================*
sys_malloc_4k edit by visual 2016.5.4
*======================================================================*/
@ -88,7 +86,6 @@ void* sys_malloc_4k()
return (void *)vir_addr;
}
/*======================================================================*
sys_free add by visual 2016.4.7
*======================================================================*/
@ -113,24 +110,3 @@ int sys_free_4k(void* AddrLin)
0 | PG_USU | PG_RWW); // 页表的属性位
return do_free_4k(phy_addr);
}
/*======================================================================*
sys_udisp_int add by visual 2016.5.16
*======================================================================*/
void sys_udisp_int(int arg)
{
disp_int(arg);
return ;
}
/*======================================================================*
sys_udisp_str add by visual 2016.5.16
*======================================================================*/
void sys_udisp_str(char *arg)
{
disp_str(arg);
return ;
}

View File

@ -13,7 +13,6 @@
#include "global.h"
#include "proto.h"
/*======================================================================*
itoa
*======================================================================*/
@ -27,16 +26,21 @@
*p++ = '0';
*p++ = 'x';
if(num == 0){
if (num == 0)
{
*p++ = '0';
}
else{
for(i=28;i>=0;i-=4){
else
{
for (i = 28; i >= 0; i -= 4)
{
ch = (num >> i) & 0xF;
if(flag || (ch > 0)){
if (flag || (ch > 0))
{
flag = TRUE;
ch += '0';
if(ch > '9'){
if (ch > '9')
{
ch += 7;
}
*p++ = ch;
@ -49,27 +53,20 @@
return str;
}
/*======================================================================*
disp_int
*======================================================================*/
void disp_int(int input)
{
char output[16];
itoa(output, input);
disp_str(output);
}
/*======================================================================*
delay
*======================================================================*/
void delay(int time)
{
int i, j, k;
for(k=0;k<time;k++){
for (k = 0; k < time; k++)
{
/*for(i=0;i<10000;i++){ for Virtual PC */
for(i=0;i<10;i++){/* for Bochs */
for(j=0;j<10000;j++){}
for (i = 0; i < 10; i++)
{ /* for Bochs */
for (j = 0; j < 10000; j++)
{
}
}
}
}

View File

@ -1,124 +0,0 @@
; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
; klib.asm
; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
; Forrest Yu, 2005
; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
%include "sconst.inc"
; 导入全局变量
extern disp_pos
[SECTION .text]
; 导出函数
global disp_str
global disp_color_str
global write_char ; added by mingxuan 2019-5-19
; ========================================================================
; void disp_str(char * info);
; ========================================================================
disp_str:
push ebp
mov ebp, esp
pushad
mov esi, [ebp + 8] ; pszInfo
mov edi, [disp_pos]
mov ah, 0Fh
.1:
lodsb
test al, al
jz .2
cmp al, 0Ah ; 是回车吗?
jnz .3
push eax
mov eax, edi
mov bl, 160
div bl
and eax, 0FFh
inc eax
mov bl, 160
mul bl
mov edi, eax
pop eax
jmp .1
.3:
;added by xw, 17/12/11
;added begin
cmp edi, 1F40h
jnz .4
mov edi, 0FA0h
.4:
;added end
mov [gs:edi], ax
add edi, 2
jmp .1
.2:
mov [disp_pos], edi
popad
pop ebp
ret
; ========================================================================
; void disp_color_str(char * info, int color);
; ========================================================================
disp_color_str:
push ebp
mov ebp, esp
pushad
mov esi, [ebp + 8] ; pszInfo
mov edi, [disp_pos]
mov ah, [ebp + 12] ; color
.1:
lodsb
test al, al
jz .2
cmp al, 0Ah ; 是回车吗?
jnz .3
push eax
mov eax, edi
mov bl, 160
div bl
and eax, 0FFh
inc eax
mov bl, 160
mul bl
mov edi, eax
pop eax
jmp .1
.3:
mov [gs:edi], ax
add edi, 2
jmp .1
.2:
mov [disp_pos], edi
popad
pop ebp
ret
; ========================================================================
; void write_char(char ch);
; ========================================================================
write_char:
push ebp
mov ebp,esp
mov esi,[ebp+8]
mov edi,[disp_pos]
push eax
mov eax,esi
mov ah, 0Fh
mov [gs:edi], ax
pop eax
pop ebp
ret

View File

@ -41,8 +41,7 @@ int main(int arg, char *argv[])
printf("%d", i);
printf("11111111111111111\n");
}
printf("\x1b[31;47mexec: path ERROR!\x1b[m");
printf("555555");
printf("\x1b[31;47m555555555555\x1b[m");
// Cursor Up
// printf("\x1b[2A");