void tsm_screen_write(struct tsm_screen *con, tsm_symbol_t ch, const struct tsm_screen_attr *attr) { unsigned int last; if (!con) return; if (con->cursor_y <= con->margin_bottom || con->cursor_y >= con->size_y) last = con->margin_bottom; else last = con->size_y - 1; if (con->cursor_x >= con->size_x) { if (con->flags & TSM_SCREEN_AUTO_WRAP) { con->cursor_x = 0; ++con->cursor_y; } else { con->cursor_x = con->size_x - 1; } } if (con->cursor_y > last) { con->cursor_y = last; screen_scroll_up(con, 1); } screen_write(con, con->cursor_x, con->cursor_y, ch, attr); ++con->cursor_x; }
static void fault_gp(isr_state_t *state) { char buffer_data[50]; char *buffer = (char *) &buffer_data; buffer = buffer_write("INT#", buffer); buffer = buffer_write_hex(state->vector, buffer); screen_write(buffer, 10, 20); }
int main(void) { SysTick_Init(); startSSI0(); initialize_screen(BACKLIGHT_ON); while(1) { clear_screen(); screen_write("Hi!\nHow are you?",ALIGN_LEFT_TOP); SysTick_Wait50ms(200); clear_screen(); screen_write("Hi!\nHow are you?",ALIGN_CENTRE_TOP); SysTick_Wait50ms(200); clear_screen(); screen_write("Hi!\nHow are you?",ALIGN_RIGHT_TOP); SysTick_Wait50ms(200); clear_screen(); screen_write("Hi!\nHow are you?",ALIGN_LEFT_CENTRE); SysTick_Wait50ms(200); clear_screen(); screen_write("Hi!\nHow are you?",ALIGN_CENTRE_CENTRE); SysTick_Wait50ms(200); clear_screen(); screen_write("Hi!\nHow are you?",ALIGN_RIGHT_CENTRE); SysTick_Wait50ms(200); clear_screen(); screen_write("Hi!\nHow are you?",ALIGN_LEFT_BOTTOM); SysTick_Wait50ms(200); clear_screen(); screen_write("Hi!\nHow are you?",ALIGN_CENTRE_BOTTOM); SysTick_Wait50ms(200); clear_screen(); screen_write("Hi!\nHow are you?",ALIGN_RIGHT_BOTTOM); SysTick_Wait50ms(200); int i=0; for(i=0;i<5;i++) { clear_screen(); screen_write("Welcome",ALIGN_RANDOM); SysTick_Wait50ms(200); } } return 0; }
// This gets called from interrupt.s void isr_handler(registers_t regs) { // This line is important. When the processor extends the 8-bit interrupt number // to a 32bit value, it sign-extends, not zero extends. So if the most significant // bit (0x80) is set, regs.int_no will be very large (about 0xffffff80). u8 int_no = regs.int_no & 0xFF; if (interrupt_handlers[int_no] != 0) { isr_t handler = interrupt_handlers[int_no]; handler(®s); } else { screen_write("unhandled interrupt: "); screen_write_dec(int_no); screen_put('\n'); for(;;); } }
SHL_EXPORT void tsm_screen_write(struct tsm_screen *con, tsm_symbol_t ch, const struct tsm_screen_attr *attr) { unsigned int last, len; if (!con) return; len = tsm_symbol_get_width(con->sym_table, ch); if (!len) return; screen_inc_age(con); if (con->cursor_y <= con->margin_bottom || con->cursor_y >= con->size_y) last = con->margin_bottom; else last = con->size_y - 1; if (con->cursor_x >= con->size_x) { if (con->flags & TSM_SCREEN_AUTO_WRAP) move_cursor(con, 0, con->cursor_y + 1); else move_cursor(con, con->size_x - 1, con->cursor_y); } if (con->cursor_y > last) { move_cursor(con, con->cursor_x, last); screen_scroll_up(con, 1); } screen_write(con, con->cursor_x, con->cursor_y, ch, len, attr); move_cursor(con, con->cursor_x + len, con->cursor_y); }
void main_bsp(void) { // Print header screen_write("Hydrogen v0.2b - http://github.com/farok/H2", 0, 0); screen_write("Copyright (c) 2012 by Lukas Heidemann", 0, 1); screen_write("-------------------------------------------------", 0, 2); // Load the IDT idt_load(idt_address, IDT_LENGTH); idt_setup_loader(); // Initialize Hydrogen info tables and parse the multiboot tables info_init(); multiboot_parse(); // Setup the heap heap_init(); // Now parse the ACPI tables and analyze the IO APICs acpi_parse(); ioapic_analyze(); // Find, check and load the kernel binary kernel_find(); kernel_check(); elf64_load(kernel_binary); kernel_analyze(); // Initialize interrupt controllers lapic_detect(); lapic_setup(); ioapic_setup_loader(); pic_setup(); // Calibrate the LAPIC timer lapic_timer_calibrate(); // Boot APs info_cpu[lapic_id()].flags |= HY_INFO_CPU_FLAG_BSP; smp_setup(); // Setup IDT and IOAPIC according to kernel header idt_setup_kernel(); ioapic_setup_kernel(); // Setup fast syscall support syscall_init(); // Setup mapping kernel_map_info(); kernel_map_stack(); kernel_map_idt(); kernel_map_gdt(); // Set free address info_root->free_paddr = (heap_top + 0xFFF) & ~0xFFF; // Lower main entry barrier and jump to the kernel entry point main_entry_barrier = 0; kernel_enter_bsp(); }