Simple Operating System
interrupts-asm.c File Reference

Kernel's interruptions. More...

#include "lib.asm"
#include "boot/io.asm"
Include dependency graph for interrupts-asm.c:

Go to the source code of this file.

Functions

void addInterrupt (number, function)
 add interruption More...
 
void setInterrupts (void)
 Set system interruptions. More...
 
void syscall (void)
 System interruption 0x20. More...
 

Detailed Description

Kernel's interruptions.

About interrupts:

When interrupt handler is called on stack are: [esp]=old eip [esp+2]=old cs [esp+4] old flags

to use local interrupt's variables DS must be changed to local i.e. KERNEL_ADDRESS

all cs of interrupt handler are KERNEL_ADDRESS - only kernel should handle

Todo:
divZero is error handle, not only zero division https://gcc.gnu.org/onlinedocs/gcc/x86-Function-Attributes.html#x86-Function-Attributes see error code

Definition in file interrupts-asm.c.

Function Documentation

◆ addInterrupt()

void addInterrupt ( number  ,
function   
)

add interruption

set *(number*4)=function

set *(number*4+2)=KERNEL_ADDRESS - only kernel can handle interruptions

Parameters
numbernew interruption number [ebp+8]
functioninterruption handler [ebp+12]

Definition at line 23 of file interrupts-asm.c.

◆ setInterrupts()

void setInterrupts ( void  )

Set system interruptions.

set syscall and errors handles

Definition at line 32 of file interrupts-asm.c.

◆ syscall()

void syscall ( void  )

System interruption 0x20.

it adds:

AH Description AL BX
0 putc() character
1 puts() address of string
2 puti() unsigned number
3 printf() address of first parameter on stack, next is 4B behind on stack etc.

Definition at line 47 of file interrupts-asm.c.