自制操作系统函数索引

自制操作系统函数索引

  • bootpack.h
bootpack.h
/* asmhead.nas */
struct BOOTINFO { /* 0x0ff0.0x0fff */ /* 5.2, 6.3, 18.7 */
char cyls; /* 引导扇区读取到磁盘的哪个位置 */
char leds; /* 引导时键盘的LED状态 */
char vmode; /* 显卡的颜色位数 */
char reserve;
short scrnx, scrny; /* 画面分辨率 */
char *vram;
};
#define ADR_BOOTINFO 0x00000ff0
#define ADR_DISKIMG 0x00100000
/* naskfunc.nas */
void io_hlt(void); /* 3.9, 4.6 */
void io_cli(void); /* 4.6 屏蔽中断,以免后面处理时有其他中断进来*/
void io_sti(void); /* 4.6 开中断(STI)*/
void io_stihlt(void); /* 4.6 先执行开中断,再执行hlt(停止)*/
int io_in8(int port); /* 4.6 */
void io_out8(int port, int data); /* 4.6 */
int io_load_eflags(void); /* 4.6 */
void io_store_eflags(int eflags); /* 4.6 */
void load_gdtr(int limit, int addr); /* 6.4 */
void load_idtr(int limit, int addr);
int load_cr0(void); /* 9.2 */
void store_cr0(int cr0); /* 9.2 */
void load_tr(int tr); /* 15.1 */
void asm_inthandler0c(void); /* 22.2 */
void asm_inthandler0d(void); /* 21.5, 21.6 */
void asm_inthandler20(void); /* 12.1, 21.4, 21.6 */
void asm_inthandler21(void); /* 6.6 */
void asm_inthandler2c(void);
unsigned int memtest_sub(unsigned int start, unsigned int end); /* 9.2, 9.3 */
void farjmp(int eip, int cs); /* 15.3 */
void farcall(int eip, int cs); /* 20.4 */
void asm_hrb_api(void); /* 20.8, 21.4, 21.6 */
void start_app(int eip, int cs, int esp, int ds, int *tss_esp0); /* 21.4, 21.6*/
void asm_end_app(void); /* 22.3 */
/* fifo.c */
struct FIFO32 { /* 13.4, 16.2 */
int *buf;
int p, q, size, free, flags;
struct TASK *task;
};
void fifo32_init(struct FIFO32 *fifo, int size, int *buf, struct TASK *task);
/* 13.4, 16.2 */
int fifo32_put(struct FIFO32 *fifo, int data); /* 13.4, 16.2, 16.4, 16.5 */
int fifo32_get(struct FIFO32 *fifo); /* 13.4 */
int fifo32_status(struct FIFO32 *fifo); /* 13.4 */
/* graphic.c */
void init_palette(void); /* 4.6, 25.2 */
void set_palette(int start, int end, unsigned char *rgb); /* 4.6 */
void boxfill8(unsgned char *vram, int xsize, unsigned char c, int x0, int y0,int x1, int y1); /* 4.7 函数功能:绘制由左上角坐标(x0,y0)和右下角坐标(x1,y1)所围成的矩形 xsize:屏幕的横向宽度 c:颜色 x0= */
void init_screen8(char *vram, int x, int y);
void putfont8(char *vram, int xsize, int x, int y, char c, char *font); /* 5.4 */
void putfonts8_asc(char *vram, int xsize, int x, int y, char c, unsigned char*s); /* 5.6, 28.5, 28.6, 28.7 */
void init_mouse_cursor8(char *mouse, char bc); /* 5.8 */
void putblock8_8(char *vram, int vxsize, int pxsize, /* 5.8 */
int pysize, int px0, int py0, char *buf, int bxsize);
#define COL8_000000 0
#define COL8_FF0000 1
#define COL8_00FF00 2
#define COL8_FFFF00 3
#define COL8_0000FF 4
#define COL8_FF00FF 5
#define COL8_00FFFF 6
#define COL8_FFFFFF 7
#define COL8_C6C6C6 8
#define COL8_840000 9
#define COL8_008400 10
#define COL8_848400 11
#define COL8_000084 12
#define COL8_840084 13
#define COL8_008484 14
#define COL8_848484 15
/* dsctbl.c */
struct SEGMENT_DESCRIPTOR { /* 5.9, 6.4 */
short limit_low, base_low;
char base_mid, access_right;
char limit_high, base_high;
};
struct GATE_DESCRIPTOR { /* 5.9 */
short offset_low, selector;
char dw_count, access_right;
short offset_high;
};
void init_gdtidt(void); /* 5.9, 12.1, 20.5, 20.8, 21.5, 21.6, 22.2 */
void set_segmdesc(struct SEGMENT_DESCRIPTOR *sd, unsigned int limit, int base,
int ar); /* 5.9, 6.4 */
void set_gatedesc(struct GATE_DESCRIPTOR *gd, int offset, int selector, int ar);
/* 5.9 */
#define ADR_IDT 0x0026f800
#define LIMIT_IDT 0x000007ff
#define ADR_GDT 0x00270000
#define LIMIT_GDT 0x0000ffff
#define ADR_BOTPAK 0x00280000
#define LIMIT_BOTPAK 0x0007ffff
#define AR_DATA32_RW 0x4092
#define AR_CODE32_ER 0x409a
#define AR_LDT 0x0082
#define AR_TSS32 0x0089
#define AR_INTGATE32 0x008e
/* int.c */
void init_pic(void); /* 6.5 */
#define PIC0_ICW1 0x0020
#define PIC0_OCW2 0x0020
#define PIC0_IMR 0x0021
#define PIC0_ICW2 0x0021
#define PIC0_ICW3 0x0021
#define PIC0_ICW4 0x0021
#define PIC1_ICW1 0x00a0
#define PIC1_OCW2 0x00a0
#define PIC1_IMR 0x00a1
#define PIC1_ICW2 0x00a1
#define PIC1_ICW3 0x00a1
#define PIC1_ICW4 0x00a1
/* keyboard.c */
void inthandler21(int *esp); /* 6.6, 7.1, 7.2, 7.3, 7.4, 7.5, 13.4 */
void wait_KBC_sendready(void); /* 7.6 */
void init_keyboard(struct FIFO32 *fifo, int data0); /* 7.6, 13.4 */
#define PORT_KEYDAT 0x0060
#define PORT_KEYCMD 0x0064
/* mouse.c */
struct MOUSE_DEC { /* 8.2, 8.3 */
unsigned char buf[3], phase;
int x, y, btn;
};
void inthandler2c(int *esp); /* 6.6, 7.7 */
void enable_mouse(struct FIFO32 *fifo, int data0, struct MOUSE_DEC *mdec); /*
7.6, 8.2, 13.4 */
int mouse_decode(struct MOUSE_DEC *mdec, unsigned char dat); /* 8.2, 8.3 */
/* memory.c */
#define MEMMAN_FREES 4090 /* 约32KB */
#define MEMMAN_ADDR 0x003c0000
struct FREEINFO { /* 剩余容量信息 */ /* 9.4 */
unsigned int addr, size;
/* addr:起始地址 size:大小*/    
};
struct MEMMAN { /*内存管理*/ /* 9.4 */
int frees, maxfrees, lostsize, losts;
/* frees:可用信息数目 maxfrees:用于观察可用状况(frees的最大值) lostsize:释放失败的内存大小总和 losts:释放失败次数*/
struct FREEINFO free[MEMMAN_FREES];
};
unsigned int memtest(unsigned int start, unsigned int end); /* 9.2 */
void memman_init(struct MEMMAN *man); /* 9.4 */
unsigned int memman_total(struct MEMMAN *man); /* 9.4 */
unsigned int memman_alloc(struct MEMMAN *man, unsigned int size); /* 9.4 */
int memman_free(struct MEMMAN *man, unsigned int addr, unsigned int size); /*
9.4 */
unsigned int memman_alloc_4k(struct MEMMAN *man, unsigned int size); /* 10.1
*/
int memman_free_4k(struct MEMMAN *man, unsigned int addr, unsigned int size);
/* 10.1 */
/* sheet.c */
#define MAX_SHEETS 256 /* 能够管理的最大图层数*/
struct SHEET { /* 10.2, 11.3, 23.8 */
unsigned char *buf;/* buf用于记录图层上所描画内容的地址(buffer)*/
int bxsize, bysize, vx0, vy0, col_inv, height, flags;
/* bxsize*bysize:即图层的整体大小 vx0和vy0表示图层在画面上位置的坐标(v即VRAM略语)col_inv:表示透明色号(color(颜色) invisible(透明)) height:表示图层高度 flags:用于存放有关图层的各种设定信息(?用于标记是否正在使用?) */    
struct SHTCTL *ctl;
struct TASK *task;
};
struct SHTCTL { /* 10.2, 11.8 */
unsigned char *vram, *map;/* vram为VRAM的地址*/
int xsize, ysize, top;/* xsize和ysize代表画面大小 top:代表最上面图层的高度*/
struct SHEET *sheets[MAX_SHEETS];/* 按高度升序排列保存图层地址*/
struct SHEET sheets0[MAX_SHEETS];/* 乱序保存各个图层的信息*/
};
struct SHTCTL *shtctl_init(struct MEMMAN *memman, unsigned char *vram, int xsize,
int ysize);
/* 10.2, 11.3, 11.8 */
struct SHEET *sheet_alloc(struct SHTCTL *ctl); /* 10.2, 23.8 用于取得新生成的未使用图层*/
void sheet_setbuf(struct SHEET *sht, unsigned char *buf, int xsize, int ysize,
int col_inv);/* 10.2 设定图层的缓冲区大小和透明色*/
void sheet_updown(struct SHEET *sht, int height); /* 10.2, 11.3, 11.7, 11.8 */
void sheet_refresh(struct SHEET *sht, int bx0, int by0, int bx1, int by1); /*10.2, 10.3, 11.3, 11.7, 11.8 向sht图层*/
void sheet_slide(struct SHEET *sht, int vx0, int vy0); /* 10.2, 10.3:记住移动前的位置,再设定新的显示位置,最后按旧、新的顺序对两个地方都进行重绘, 11.3,
11.7, 11.8 */
void sheet_free(struct SHEET *sht); /* 10.2, 11.3 */
/* timer.c */
#define MAX_TIMER 500
struct TIMER { /* 12.4, 13.4, 13.5, 24.8 */
struct TIMER *next;
unsigned int timeout;
char flags, flags2;
struct FIFO32 *fifo;
int data;
};
struct TIMERCTL { /* 12.2, 12.3, 12.4, 12.6, 12.7, 13.5 */
unsigned int count, next;
struct TIMER *t0;
struct TIMER timers0[MAX_TIMER];
};
extern struct TIMERCTL timerctl;
void init_pit(void); /* 12.1, 12.2, 12.3, 12.4, 12.6, 12.7, 13.6 */
struct TIMER *timer_alloc(void); /* 12.4, 12.7, 24.8 */
void timer_free(struct TIMER *timer); /* 12.4 */
void timer_init(struct TIMER *timer, struct FIFO32 *fifo, int data); /* 12.4,
13.4 */
void timer_settime(struct TIMER *timer, unsigned int timeout); /* 12.4, 12.5,
12.6, 12.7, 13.5, 13.6 */
void inthandler20(int *esp); /* 12.1, 12.2, 12.3, 12.4, 12.5, 12.6, 12.7,
13.4, 13.5, 13.6, 15.7 */
int timer_cancel(struct TIMER *timer); /* 24.8 */
void timer_cancelall(struct FIFO32 *fifo); /* 24.8 */
/* mtask.c */
#define MAX_TASKS 1000 /* 最大任务数量 */
#define TASK_GDT0 3 /* TSS从GDT的几号开始分配 */
#define MAX_TASKS_LV 100
#define MAX_TASKLEVELS 10
struct TSS32 { /* 15.1, 16.1 */
int backlink, esp0, ss0, esp1, ss1, esp2, ss2, cr3;
int eip, eflags, eax, ecx, edx, ebx, esp, ebp, esi, edi;
int es, cs, ss, ds, fs, gs;
int ldtr, iomap;
};
struct TASK { /* 16.1, 16.4, 16.5, 17.4, 25.6, 26.7, 27.4, 28.3, 28.4, 28.5,
28.6 */
int sel, flags; /* sel代表GDT编号*/
int level, priority;
struct FIFO32 fifo;
struct TSS32 tss;
struct SEGMENT_DESCRIPTOR ldt[2];
struct CONSOLE *cons;
int ds_base, cons_stack;
struct FILEHANDLE *fhandle;
int *fat;
char *cmdline;
unsigned char langmode, langbyte1;
};
struct TASKLEVEL { /* 16.5 */
int running; /*活动的任务数量*/
int now; /*保存当前活动任务的变量*/
struct TASK *tasks[MAX_TASKS_LV];
};
struct TASKCTL { /* 16.1, 16.5 */
int now_lv; /*当前活动的层级 */
char lv_change; /* 下次切换任务时是否需要改变层级 */
struct TASKLEVEL level[MAX_TASKLEVELS];
struct TASK tasks0[MAX_TASKS];
};
extern struct TASKCTL *taskctl;
extern struct TIMER *task_timer;
struct TASK *task_now(void); /* 16.5 */
struct TASK *task_init(struct MEMMAN *memman); /* 16.1, 16.4, 16.5, 17.1, 27.4
*/
struct TASK *task_alloc(void); /* 16.1, 22.3, 27.4 */
void task_run(struct TASK *task, int level, int priority); /* 16.1, 16.4, 16.5
*/
void task_switch(void); /* 16.1, 16.4, 16.5 */
void task_sleep(struct TASK *task); /* 16.2, 16.5 */
/* window.c */
void make_window8(unsigned char *buf, int xsize, int ysize, char *title, char
act); /* 11.4, 16.3, 17.3 */
void putfonts8_asc_sht(struct SHEET *sht, int x, int y, int c, int b, char *s,
int l); /* 13.1, 29.1 */
void make_textbox8(struct SHEET *sht, int x0, int y0, int sx, int sy, int c);
/* 14.6 */
void make_wtitle8(unsigned char *buf, int xsize, char *title, char act); /*
17.3 */
void change_wtitle8(struct SHEET *sht, char act); /* 24.5 */
/* console.c */
struct CONSOLE { /* 20.1, 23.6 */
struct SHEET *sht;
int cur_x, cur_y, cur_c;
struct TIMER *timer;
};
struct FILEHANDLE { /* 28.3 */
char *buf;
int size;
int pos;
};
void console_task(struct SHEET *sheet, int memtotal);
/* 17.2, 17.4, 18.2, 18.3, 18.4, 18.5, 18.6, 18.7, 19.1, 19.2, 19.3,19.5,
20.1, 20.2, 25.6, 25.10, 26.8, 26.10, 27.2, 28.3, 28.4, 28.5, 28.6 */
void cons_putchar(struct CONSOLE *cons, int chr, char move); /* 20.1, 26.10 */
void cons_newline(struct CONSOLE *cons); /* 20.1, 26.10, 28.6 */
void cons_putstr0(struct CONSOLE *cons, char *s); /* 20.8 */
void cons_putstr1(struct CONSOLE *cons, char *s, int l); /* 20.8 */
void cons_runcmd(char *cmdline, struct CONSOLE *cons, int *fat, int memtotal);
/* 20.1, 20.6, 20.8, 26.7, 26.9, 26.10, 28.5 */
void cmd_mem(struct CONSOLE *cons, int memtotal); /* 20.1, 20.8 */
void cmd_cls(struct CONSOLE *cons); /* 20.1 */
void cmd_dir(struct CONSOLE *cons); /* 20.1, 20.8 */
void cmd_exit(struct CONSOLE *cons, int *fat); /* 26.7, 26.10 */
void cmd_start(struct CONSOLE *cons, char *cmdline, int memtotal); /* 26.9 */
void cmd_ncst(struct CONSOLE *cons, char *cmdline, int memtotal); /* 26.10 */
void cmd_langmode(struct CONSOLE *cons, char *cmdline); /* 28.5, 28.7 */
int cmd_app(struct CONSOLE *cons, int *fat, char *cmdline);
/* 20.6, 21.1, 21.2, 21.4, 21.6, 22.4, 23.8, 24.5, 24.8, 25.6, 25.7, 27.4,
28.3, 28.6, 29.2 */
int *hrb_api(int edi, int esi, int ebp, int esp, int ebx, int edx, int ecx, int
eax);
/* 21.6, 22.1, 22.4, 22.5, 22.6, 23.1, 23.2, 23.3, 23.4, 23.5, 23.6, 23.8,
24.5, 24.7, 24.8, 25.1, 25.4, 25.6, 26.2, 27.2, 28.3, 28.4, 28.7, 29.2,
29.5 */
int *inthandler0d(int *esp); /* 21.6, 22.2, 25.6 */
int *inthandler0c(int *esp); /* 22.2, 25.6 */
void hrb_api_linewin(struct SHEET *sht, int x0, int y0, int x1, int y1, int col);
/* 23.4 */
/* file.c */
struct FILEINFO { /* 18.7, 19.1 */
unsigned char name[8], ext[3], type;
char reserve[10];
unsigned short time, date, clustno;
unsigned int size;
};
void file_readfat(int *fat, unsigned char *img); /* 19.3 */
void file_loadfile(int clustno, int size, char *buf, int *fat, char *img); /*
19.3 */
struct FILEINFO *file_search(char *name, struct FILEINFO *finfo, int max); /*
20.1 */
char *file_loadfile2(int clustno, int *psize, int *fat); /* 29.2 */
/* tek.c */
int tek_getsize(unsigned char *p); /* 29.2 */
int tek_decomp(unsigned char *p, char *q, int size); /* 29.2 */
/* bootpack.c */
struct TASK *open_constask(struct SHEET *sht, unsigned int memtotal); /* 26.10
*/
struct SHEET *open_console(struct SHTCTL *shtctl, unsigned int memtotal); /*
26.5, 26.7, 26.10 */
■■■■■
apilib.h
void api_putchar(int c); /* 21.2, 21.6, 27.5 */
void api_putstr0(char *s); /* 22.4, 27.5 */
void api_putstr1(char *s, int l); /* 27.5 */
void api_end(void); /* 21.6 */
int api_openwin(char *buf, int xsiz, int ysiz, int col_inv, char *title); /*
22.5 */
void api_putstrwin(int win, int x, int y, int col, int len, char *str); /* 22.6
*/
void api_boxfilwin(int win, int x0, int y0, int x1, int y1, int col); /* 22.6
*/
void api_initmalloc(void); /* 23.1 */
char *api_malloc(int size); /* 23.1 */
void api_free(char *addr, int size); /* 23.1 */
void api_point(int win, int x, int y, int col); /* 23.2 */
void api_refreshwin(int win, int x0, int y0, int x1, int y1); /* 23.3 */
void api_linewin(int win, int x0, int y0, int x1, int y1, int col); /* 23.4 */
void api_closewin(int win); /* 23.5 */
int api_getkey(int mode); /* 23.6 */
int api_alloctimer(void); /* 24.7 */
void api_inittimer(int timer, int data); /* 24.7 */
void api_settimer(int timer, int time); /* 24.7 */
void api_freetimer(int timer); /* 24.7 */
void api_beep(int tone); /* 25.1 */
int api_fopen(char *fname); /* 28.3 */
void api_fclose(int fhandle); /* 28.3 */
void api_fseek(int fhandle, int offset, int mode); /* 28.3 */
int api_fsize(int fhandle, int mode); /* 28.3 */
int api_fread(char*buf,int maxsize,int fandle);/*28.3*/
int api_cmdline(char*buf,int maxsize);/*28.4*/
int api_getlang(void);/*28.7*/



i n t a p i _ f r e a d ( c h a r * b u f , i n t m a x s i z e , i n t f h a n d l e ) ; / * 2 8.3 * /

i n t a p i _ c m d l i n e ( c h a r * b u f , i n t m a x s i z e ) ; / * 2 8.4 * /

i n t a p i _ g e t l a n g ( v o i d ) ; / * 2 8.7 * /

posted @ 2023-03-03 10:15  浩泽郎  阅读(20)  评论(0编辑  收藏  举报