Example #1
0
void monitor_write_dec(s32int number){
    char *converted = dec_to_string(number);
    monitor_write(converted);
    monitor_put('\n');
}
Example #2
0
// Output a null-terminated ASCII string to the monitor.
void monitor_write(char *c)
{
	int i = 0;
	while(c[i])
		monitor_put(c[i++]);
}
Example #3
0
int main(struct multiboot *mboot_ptr, u32int initial_stack)
{
    initial_esp = initial_stack;
    // Initialise all the ISRs and segmentation
    init_descriptor_tables();
    // Initialise the screen (by clearing it)
    monitor_clear();
    // Initialise the PIT to 100Hz
    asm volatile("sti");
    init_timer(50);

    // Find the location of our initial ramdisk.
    ASSERT(mboot_ptr->mods_count > 0);
    u32int initrd_location = *((u32int*)mboot_ptr->mods_addr);
    u32int initrd_end = *(u32int*)(mboot_ptr->mods_addr+4);
    // Don't trample our module with placement accesses, please!
    placement_address = initrd_end;

    // Start paging.
    initialise_paging();

    // Start multitasking.
    initialise_tasking();

    // Initialise the initial ramdisk, and set it as the filesystem root.
    fs_root = initialise_initrd(initrd_location);

    // Create a new process in a new address space which is a clone of this.
    int ret = fork();

    monitor_write("fork() returned ");
    monitor_write_hex(ret);
    monitor_write(", and getpid() returned ");
    monitor_write_hex(getpid());
    monitor_write("\n============================================================================\n");

    // The next section of code is not reentrant so make sure we aren't interrupted during.
    asm volatile("cli");
    // list the contents of /
    int i = 0;
    struct dirent *node = 0;
    while ( (node = readdir_fs(fs_root, i)) != 0)
    {
        monitor_write("Found file ");
        monitor_write(node->name);
        fs_node_t *fsnode = finddir_fs(fs_root, node->name);

        if ((fsnode->flags&0x7) == FS_DIRECTORY)
        {
            monitor_write("\n\t(directory)\n");
        }
        else
        {
            monitor_write("\n\t contents: \"");
            char buf[256];
            u32int sz = read_fs(fsnode, 0, 256, buf);
            int j;
            for (j = 0; j < sz; j++)
                monitor_put(buf[j]);
            
            monitor_write("\"\n");
        }
        i++;
    }
    monitor_write("\n");

    asm volatile("sti");

    return 0;
}
Example #4
0
void monitor_write_hex(u32int value){
    char *converted = hex_to_string(value);
    monitor_write("0x");
    monitor_write(converted);
    monitor_put('\n');
}
Example #5
0
void monitor_print(char* str) {
    if(str != NULL) {
    	while(*str != 0)
    		monitor_put(*(str++));
    }
}
Example #6
0
void isr_handler(registers_t regs)
{
   monitor_write("recieved interrupt: ");
   monitor_write_dec(regs.int_no);
   monitor_put('\n');
}
Example #7
0
static void printit(INT32 chr, APTR ptr)
{
	monitor_put(chr);
}
Example #8
0
void keyboard_handler ( registers_t *regs ) {
	u8int scancode = inb ( 0x60 );
	u8int specialKey = 0;
	specialKey = isSpecialKey ( scancode );
	currentKey = 0;

	if ( scancode & 0x80 ) {
		scancode = scancode - 0x80;

		if ( scancode == 42 || scancode - 0x80 == 54 ) {
			shift_flag = 0;
		}

	} else {
		if ( scancode == 42 || scancode - 0x80 == 54 ) {
			shift_flag = 1;
		}

		if ( scancode == 0x3A ) {
			CapsOn = !CapsOn;
			i8042_Caps(CapsOn, 0, 0);
		}

		if ( shift_flag == 0 && CapsOn == 0 ) {
			//monitor_put ( lowerCaseKbdus[scancode] );
			setKey ( lowerCaseKbdus[scancode] ); //set Current Key for key logger.
		}

		if ( shift_flag == 1 || CapsOn == 1 ) {
			//monitor_put ( upperCaseKbdus[scancode] );
			setKey ( upperCaseKbdus[scancode] ); //set Current Key for key logger.
		}

		//monitor_put(currentKey); //standard print keys to screen

		if ( specialKey != 0 ) {
			switch ( specialKey ) {
			case 1:
				monitor_command ( "cursor", "left" );
				break;

			case 2:
				monitor_command ( "cursor", "right" );
				break;

			case 3:
				monitor_command ( "cursor", "up" );
				break;

			case 4:
				monitor_command ( "cursor", "down" );
				break;

			case 5:
				monitor_put ( '\r' );
				setKey ( '\r' );
				break;

			default:
				break;
			}

		}
	}
	
	
	//i8042_Caps(CapsOn, 0, 0);
}
Example #9
0
File: keyb.c Project: phase/cakeos
/* Handles the keyboard interrupt */
static void keyboard_handler(registers_t* regs)
{
    unsigned char scancode;

    //Read scancode
    scancode = inb(0x60);
    
    switch (scancode)
    {
           case 0x3A:
                /* CAPS_LOCK LEDS */
                outb(0x60,0xED);
                ltmp |= 4;
                outb(0x60,ltmp);
                
                if(caps_flag)
                caps_flag=0;
                else
                caps_flag=1;
                break;
           case 0x45:
                /* NUM_LOCK LEDS */
                outb(0x60,0xED);
                ltmp |= 2;
                outb(0x60,ltmp);
                break;
           case 0x46:
                /* SCROLL_LOCK LEDS */
                outb(0x60,0xED);
                ltmp |= 1;
                outb(0x60,ltmp);
                break;
           case 60: /* F12 */
                reboot();
                break;
           default:
                break;
    }

    if (scancode & 0x80)
    {
        //Key release
        
        //Left and right shifts
        if (scancode - 0x80 == 42 || scancode - 0x80 == 54)
			shift_flag = 0;
    } else {   
        //Keypress (normal)
        
        //Shift
        if (scancode == 42 || scancode == 54)
		{
			shift_flag = 1;
			return;
		}
        
        //Gets()
        if(kbdus[scancode] == '\n')
        {
             if(gets_flag == 0) do_gets();
             gets_flag++;
             for(;kb_count; kb_count--)
                  buffer[kb_count] = 0;              
        } else {
             if(kbdus[scancode] == '\b')
             {
                  if(kb_count)
                  buffer[kb_count--] = 0;
             } else {
                  buffer[kb_count++] = kbdus[scancode];
             }
                  
        } 
        
        //Print key
        if(graphical_mode == 2)
        {
             if(current_window.id != 0)
             {
                  if(kbdus[scancode] >= 97 && kbdus[scancode] <= 122)
                       plot_char_abs(shell_csr_x, shell_csr_y, (kbdus[scancode]-32), WINDOW_COLOUR_TOPBAR_TEXT, current_window.width, (u32int*)current_window.data);
                  else
                       plot_char_abs(shell_csr_x, shell_csr_y, kbdus[scancode], WINDOW_COLOUR_TOPBAR_TEXT, current_window.width, (u32int*)current_window.data);
                  put_buffer(current_window.x,current_window.y,current_window.width,current_window.height,(u32int*)current_window.data);
             } else {
                  if(kbdus[scancode] >= 97 && kbdus[scancode] <= 122)
                        vgaPutchar (g_csr_x,g_csr_y,(kbdus[scancode]-32),WINDOW_COLOUR_TOPBAR_TEXT);
                  else
                        vgaPutchar (g_csr_x,g_csr_y,(kbdus[scancode]),WINDOW_COLOUR_TOPBAR_TEXT);
                  refresh_screen();
             }
        } else {
        if(graphical_mode == 1)
        {
             if(kbdus[scancode] >= 97 && kbdus[scancode] <= 122)
                  vgaPutchar (g_csr_x,g_csr_y,(kbdus[scancode]-32),1); //A-Z
             else
                  vgaPutchar (g_csr_x,g_csr_y,(kbdus[scancode]),1); //0-9
             refresh_screen();
        } else
             monitor_put(kbdus[scancode]);
        }
        return;
    }
}