Example #1
0
File: main.c Project: Nico01/unidos
// callback for handling interrupt
void hook_intr(uc_engine *uc, uint32_t intno, void *user_data)
{
    uint32_t r_ip;
    uint8_t r_ah;

    uc_reg_read(uc, UC_X86_REG_IP, &r_ip);
    uc_reg_read(uc, UC_X86_REG_AH, &r_ah);

    // only handle DOS interrupt
    switch(intno) {
        default:
            printf(">>> 0x%x: interrupt: %x, function %x\n", r_ip, intno, r_ah);
            break;
        case 0x21:
            int21(uc);
            break;
        case 0x20:
            int20(uc);
            break;
    }
}
Example #2
0
void dokernel()
{
	/*placeholder for the shell*/
	char file[12800];

	/*some friendly startup messages*/
	bios_printstr("\r\nBuild an Operating System from Scratch Project\r\n\0");
	bios_printstr("Written by Michael Black, December, 2007\r\n\n\0");
	bios_printstr("Starting the kernel\r\n\0");

	/*make the process table*/ 
	initialize_process_table();
	bios_printstr("Process table is initialized\r\n\0");

	/*install the ISR for interrupt 21*/
	makeinterrupt21();

	int21(1,"Interrupt 21 is installed\r\n\0");

	int21(1,"Kernel set up is completed\r\n\0");
	int21(1,"Loading the shell into memory\r\n\0");

	/*start the shell*/
	/*load it into file[]*/
	int21(3,"SHELL\0",file);

	/*load it to memory and schedule it to be executed*/
	int21(6,file,12800,"SHELL\0");

	/*install an ISR for the timer - this will call the scheduler*/
	maketimerinterrupt();

	int21(1,"Timer interrupt is installed\r\n\0");

	int21(1,"\r\nThe shell is starting.  The kernel will stay in the background.\r\n\n\0");
}
Example #3
0
/*kill a process*/
void dokill(char* line)
{
	/*make the system call*/
	char* arg=getargument(line);
	int21(9,arg[0]-0x30);
}
Example #4
0
void executeprogram(char* buffer, int bytelength)
{
	int21(8,buffer,bytelength);
}
Example #5
0
void deletefile(char* name)
{
	int21(5,name);
}
Example #6
0
void writefile(char* name, char* buffer, int sectorlength)
{
	int21(4,name,buffer,sectorlength);
}
Example #7
0
void readfile(char* name, char* buffer)
{
	int21(3,name,buffer);
}
Example #8
0
void readstring(char* buffer)
{
	int21(2,buffer);
}
Example #9
0
void printstring(char* string)
{
	int21(1,string);
}
Example #10
0
void exit()
{
	int21(7);
}
Example #11
0
void executeprogrambackground(char* buffer, int bytelength)
{
	int21(6,buffer,bytelength);
}
Example #12
0
void ps()
{
    int21(17);
}