我的学习之旅(23)traps.c和 start32.h

49 篇文章 0 订阅
49 篇文章 0 订阅

接下来就要先初始化中断向量。如书上所说,intel默认保留使用了0~31个中断给自己使用。这些中断目前不想处理。所以这些中断的处理函数只是打印一下就可以。

traps.c源代码:

#include <io.h>
#include <start32.h>
#include <system.h>

void default_handle(void);

void do_default_handle()
{
    /*do nothing by now.*/
    printk("default handle\n");

    return;
}

void trap_init(void)
{
    int i;
    //32个中断为intel保留使用, 8259-1使用8个中断,8259-2使用8个中断,所以总共要加48个中断处理函数。

    for( i = 0; i < 48; i++ )  

  {
        set_trap_gate(i, &default_handle);
    }
}

//start32.h 拷贝自linux源代码中的head.h

-------

#ifndef __START32_H__

#define __START32_H__
/*copy from linux source code: head.h*/

typedef struct desc_struct {
 unsigned long a,b;
} desc_table[256];
extern desc_table idt,gdt;

#define GDT_NUL 0
#define GDT_CODE 1
#define GDT_DATA 2
#define GDT_TMP 3

#define LDT_NUL 0
#define LDT_CODE 1
#define LDT_DATA 2

#endif
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值