From 82053201102958f2092cdcf2cc0018b33ca3d002 Mon Sep 17 00:00:00 2001 From: Yourtion Date: Fri, 12 Sep 2014 16:37:27 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96PIC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 06_day/Makefile | 5 +++-- 06_day/bootpack.c | 2 ++ 06_day/bootpack.h | 15 +++++++++++++++ 06_day/int.c | 25 +++++++++++++++++++++++++ 4 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 06_day/int.c diff --git a/06_day/Makefile b/06_day/Makefile index d24cb0d..199cdee 100644 --- a/06_day/Makefile +++ b/06_day/Makefile @@ -1,4 +1,5 @@ -OBJS_BOOTPACK = bootpack.obj naskfunc.obj hankaku.obj graphic.obj dsctbl.obj +OBJS_BOOTPACK = bootpack.obj naskfunc.obj hankaku.obj graphic.obj dsctbl.obj \ + int.obj TOOLPATH = ../z_tools/ INCPATH = ../z_tools/haribote/ @@ -64,7 +65,7 @@ haribote.img : ipl10.bin haribote.sys Makefile %.obj : %.nas Makefile $(NASK) $*.nas $*.obj $*.lst -# �R�}���h +# 运行程序 img : $(MAKE) haribote.img diff --git a/06_day/bootpack.c b/06_day/bootpack.c index c10411b..8155700 100644 --- a/06_day/bootpack.c +++ b/06_day/bootpack.c @@ -10,6 +10,8 @@ void HariMain(void) int mx, my; init_gdtidt(); + init_pic(); + init_palette(); init_screen8(binfo->vram, binfo->scrnx, binfo->scrny); mx = (binfo->scrnx - 16) / 2; /* 计算画面的中心坐标*/ diff --git a/06_day/bootpack.h b/06_day/bootpack.h index 7880d5a..ef3a2ac 100644 --- a/06_day/bootpack.h +++ b/06_day/bootpack.h @@ -67,3 +67,18 @@ void set_gatedesc(struct GATE_DESCRIPTOR *gd, int offset, int selector, int ar); #define LIMIT_BOTPAK 0x0007ffff #define AR_DATA32_RW 0x4092 #define AR_CODE32_ER 0x409a + +/* int.c */ +void init_pic(void); +#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 \ No newline at end of file diff --git a/06_day/int.c b/06_day/int.c new file mode 100644 index 0000000..fc945e0 --- /dev/null +++ b/06_day/int.c @@ -0,0 +1,25 @@ +/*初始化关系 */ + +#include "bootpack.h" + +void init_pic(void) +/* PIC初始化 */ +{ + io_out8(PIC0_IMR, 0xff ); /* 禁止所有中断 */ + io_out8(PIC1_IMR, 0xff ); /* 禁止所有中断 */ + + io_out8(PIC0_ICW1, 0x11 ); /* 边缘触发模式(edge trigger mode) */ + io_out8(PIC0_ICW2, 0x20 ); /* IRQ0-7由INT20-27接收 */ + io_out8(PIC0_ICW3, 1 << 2); /* PIC1由IRQ2相连 */ + io_out8(PIC0_ICW4, 0x01 ); /* 无缓冲区模式 */ + + io_out8(PIC1_ICW1, 0x11 ); /* 边缘触发模式(edge trigger mode) */ + io_out8(PIC1_ICW2, 0x28 ); /* IRQ8-15由INT28-2f接收 */ + io_out8(PIC1_ICW3, 2 ); /* PIC1由IRQ2连接 */ + io_out8(PIC1_ICW4, 0x01 ); /* 无缓冲区模式 */ + + io_out8(PIC0_IMR, 0xfb ); /* 11111011 PIC1以外全部禁止 */ + io_out8(PIC1_IMR, 0xff ); /* 11111111 禁止所有中断 */ + + return; +}