阅读:2123回复:8
dos下如何打开IRQ的硬件中断
原认为在dos下挂接IRQ的硬件中断很简单,但作了之后,才知不是如此。不知如何初始化。请大虾指点一二,我的实验具体如下:
1。 选用X386的IRG5作中断口。 2。在ISA总线的IRQ5上接一个脉冲源。3。编写一中断程序(只让全程变量自加1)挂接在向量0X0D上。4。主程序循环显示全程变量。 但无中断触发。 *为初始化类时8259的中断芯片行吗? 请各位多多指教。小弟已焦头矣!!!那里有这方面的资料(书\\网址)。 |
|
|
沙发#
发布于:2002-07-01 10:30
First, You should make sure that what vector IRQ0 is hooked on.(Mostly on vector 8). If you are not sure, re-program the 8259 interrupt controller.
Second, when you install your interrupt handler, switch off interrupt. Third, after you installed your interrupt handler, switch on interrupt. Fourth, MAKE SURE that you send a EOI command to the 8259. If you do not send this command, next interrupt will not be responsed. Fifth, DO NOT use printf function to show some information in the interrupt handler. Cause printf will arise another interrupt, since you switched off interrupt. Sixth, If you do not know how to control 8259. Read this book: The Undocumented PC(PC技术内幕)by Frank van Gilluwe. or other books |
|
板凳#
发布于:2002-07-01 15:55
刨根问底-----
在I386上针对8259的编程方式,用此编程能否运行在I386的82380的集成芯片中 |
|
|
地板#
发布于:2002-07-01 15:56
刨根问底-----
在I386上针对8259的编程方式,用此编程能否运行在I386的82380的集成芯片中 |
|
|
地下室#
发布于:2002-07-01 17:13
请注意20H,21H I/O PORT是否设置好!有没有别的设备占用IRQ5。
还有ISA卡本身硬件设计时是否已经开放IRQ |
|
5楼#
发布于:2002-07-01 22:23
ISA槽上没有任何硬件。用 out 21h,al (al=0) 清除所有的中断屏蔽位。中断程序的挂接, 用int 0xd 测试--挂接成功。但去除int 0xd 后中断产生。 请诸位高手不吝赐教!谢谢!最好能提供一个样例为盼!!!!
|
|
|
6楼#
发布于:2002-07-02 08:53
The simple example of initialize 8259. It is AT&T format asm. \"opcode source, destination\"
movb $0x11, %al #Initialize 8259-1 outb %al, $0x20 call dumy_loop movb $0x20, %al #IRQ 0-7, link to interrupt vector 0x20 outb %al, $0x21 call dumy_loop movb $0x04, %al outb %al, $0x21 call dumy_loop movb $0x01, %al outb %al, $0x21 call dumy_loop movb $0xfd, %al #Mask all interrupts except keyboard outb %al, $0x21 call dumy_loop movb $0x11, %al #Initialize 8259-2 outb %al, $0xa0 call dumy_loop movb $0x28, %al #IRQ 8-15, link to interrupt vector 0x28 outb %al, $0xa1 call dumy_loop movb $0x02, %al outb %al, $0xa1 call dumy_loop movb $0x01, %al outb %al, $0xa1 call dumy_loop movb $0xff, %al #Mask all interrupts outb %al, $0xa1 call dumy_loop Please check your card\'s documents. In interrupt handler, most of hardware recommmands that some status register should be read. In this way, it can clear pending interrupt and receive another interrupt. For example, the keyboard: The keyboard interrupt handler #keyboard.asm .text .globl kbd_int_handler kbd_int_handler: pusha call kbd_handler popa iret /*kbd.c*/ #define read_scan_code(x) __asm__(\"pushw %%ax\\n \\ inb $0x60, %%al\\n \\ movb %%al, %0\\n \\ popw %%ax\\n\" \\ : \"=m\"(x) \\ ); #define end_of_interrupt() __asm__(\"pushw %%ax\\n \\ movb $0x20, %%al\\n \\ outb %%al, $0xa0\\n \\ jmp 1f\\n \\ 1: jmp 1f\\n \\ 1: outb %%al, $0x20\\n \\ jmp 1f\\n \\ 1: jmp 1f\\n \\ 1: popw %%ax\\n\":: \\ ); void kbd_handler(void) { unsigned char ascii_val; void (*func)(); read_scan_code(scan_val); if((scan_val != 0xe0) && (scan_val != 0xe1)) { func = func_map[scan_val]; (*func)(); } process_tty_input_queue(&tty_table[0]); end_of_interrupt(); return; } If you do not read a byte from keyboard buffer(\"read_scan_code\" that is reading a byte from port 0x60). There will be a pending interrupt, and when you strike the key next time, keybord interrupt will not arise. So, check your ISA hardware\'s doc. Maybe there is a port you should read and clear the pending interrupt. |
|
7楼#
发布于:2002-07-31 16:57
用得着这么复杂吗?
在main()中:setvect(0x0d,newint0d); 在程序中: void interrupt newint0d(...) { ..... outputb(0x20,0x20); } 你可以先用中断0x1C(时钟中断)试,通过后再改成0d。 |
|
8楼#
发布于:2002-08-02 09:02
If all things are as easy as what you think, we programmers world rather go home and paly with our children!!
|
|