Ejemplo n.º 1
0
context_t *load(context_t *ctx, char *filename, char *data)
{
    char *buf = strdup(data);
    char *saveptr;
    char *line = strtok_r(buf, "\n", &saveptr);
    int lineno = 1;

    while (line != NULL)
    {
        interpret(ctx, line);
        if (ctx->state == ERROR)
        {
            printf("  in '%s' at line %d:\n", filename, lineno);
            terminal_setcolor(0x0F);
            printf("%s\n", line);
            terminal_setcolor(0x07);
            break;
        }

        line = strsep(&saveptr, "\n");
        lineno++;
    }

    free(buf);
    return ctx;
}
Ejemplo n.º 2
0
bool init_screen() {
	terminal_initialize();

	terminal_setcolor(make_color(FGCOLOR, BGCOLOR));
	terminal_clear();

	terminal_printf("Welcome to ");
	terminal_setcolor(make_color(COLOR_MAGENTA, BGCOLOR));
	terminal_printf("%s", __KERNEL_NAME);

	terminal_setcolor(make_color(FGCOLOR, BGCOLOR));
	terminal_printf(" multiboot32 => kernel loader\n");
	return true;
}
Ejemplo n.º 3
0
int cleanWrap(char *arg)
{
  (void)arg;
  clean();
  terminal_setpos(0, 0);
  terminal_setcolor(make_color(COLOR_LIGHT_GREY, COLOR_BLACK));
  return (0);
}
Ejemplo n.º 4
0
void terminal_writerainbow(const char *data) {
    size_t datalen = strlen(data);
    for (size_t i = 0; i < datalen; i++) {
        uint8_t fg = terminal_color;
        uint8_t bg = terminal_color >> 4;
        terminal_setcolor(make_color(++fg % NUMCOLORS, ++bg % NUMCOLORS));
        terminal_putchar(data[i]);
    }
}
Ejemplo n.º 5
0
void print_requirement(const char *text, bool have) {
	terminal_setcolor(make_color(FGCOLOR, BGCOLOR));
	terminal_printf(" - %s ", text);

	size_t textlen = strlen(text);
	for (size_t pneed = textlen; pneed < 32; pneed++) {
		terminal_putchar('.');
	}

	terminal_putchar('[');
	if (have) {
		terminal_setcolor(make_color(COLOR_GREEN, BGCOLOR));
		terminal_writestring("OK");
	} else {
		terminal_setcolor(make_color(COLOR_RED, BGCOLOR));
		terminal_writestring("FAIL");
	}
	terminal_setcolor(make_color(FGCOLOR, BGCOLOR));
	terminal_writestring("]\n");
}
Ejemplo n.º 6
0
void kernel_main() {
    /* Initialize terminal interface */
    terminal_initialize();

    terminal_writestring("You shouldn't see this string if scrolling works...\n");
    for (size_t row = 0; row < VGA_HEIGHT - 1; row++) {
        terminal_writerainbow("Hello kernel world!\n");
    }
    terminal_setcolor(COLOR_LIGHT_GREY);
    terminal_writestring("Reached bottom of terminal");

}
Ejemplo n.º 7
0
void drawImage(enum vga_color img[25][80])
{
    size_t x, y;
    for (x = 0; x < 80; ++x)
    {
        for (y = 0; y < 25; ++y)
        {
            terminal_set_pos(x,y);
            terminal_setcolor(0, img[y][x]);
            terminal_writestring(" ");
        }
    }
}
Ejemplo n.º 8
0
void drawBox(size_t minX, size_t minY, size_t  maxX, size_t maxY, enum vga_color fg, enum vga_color bg)
{
    size_t x, y;
    terminal_setcolor(fg, bg);

    for (x = minX; x < maxX; ++x)
    {
        for (y = minY; y < maxY; ++y)
        {
            terminal_set_pos(x, y);
            terminal_writestring(" ");
        }
    }

}
Ejemplo n.º 9
0
void kernel_main()
{
	terminal_cls(COLOR_LIGHT_BLUE);
	terminal_setcolor(make_color(COLOR_WHITE, COLOR_LIGHT_BLUE));
	/* Since there is no support for newlines in terminal_putchar yet, \n will
	   produce some VGA specific character instead. This is normal. */
	terminal_writestring("Hello, kernel World!\n");

	terminal_printf("This is the base string terminal system !\n");

	if(apros_setup_gdt() > 0)
		terminal_printf("GDT correctly setted !\n");
	if(apros_setup_idt())
		terminal_printf("IDT correctly setted ! \n");

	for(;;)
		continue;
}
Ejemplo n.º 10
0
// This function handles all interrupts.
void fault_handler(struct regs *r)
{
    dbgprint("interrupt!\n");
    if (interrupt_handlers[r->int_no] != 0) {
        (interrupt_handlers[r->int_no]) (r->int_no, r->int_no); // not sure what the second param is for...
        return;
    }
    // unhandled!
    // Is this a fault whose number is from 0 to 31?
    if (r->int_no < 32)
    {
        if (!current) {
            if (r->int_no == 2) {
                // it's an NMI. oh noes
                // we shouldn't do much other than text, to avoid triggering the faulty hardware again

                terminal_initialize(); // clear terminal
                terminal_setcolor(COLOR_RED); // set it to a spooky color

                // show scary message for scary error
                terminal_writestring("*** NON-MASKABLE INTERRUPT OCCURRED ***\n\n");

                terminal_writestring("To protect your computer and data, HexOS has stopped.\n\n");

                terminal_writestring("A critical non-recoverable and non-maskable hardware interrupt has occurred. This may mean that your computer's hardware is defective. If this error occurs multiple times, try isolating the problem by removing and/or replacing components.");
                while (1) {}
            }
            printf("Error code: %d\n", r->err_code);
            // Display the description for the Exception that occurred.
            panic(exception_messages[r->int_no]);
            for (;;);
        } else {
            // TODO: signal the process rather than kill it
            process_exit(-1, exception_messages[r->int_no]); // kill the process
        }
    }
}
Ejemplo n.º 11
0
void draw_logo(void)
{
    char c, *data;
    terminal_clear();
    data = logo;
    while ((c = *data++) != '\0' )
    {
        switch (c)
        {
            case '_':
                terminal_setcolor(0x08); // Dark Grey
                terminal_putchar('_');
                break;

            case '/':
                terminal_setcolor(0x0A); // Green
                terminal_putchar('/');
                break;

            case 'X':
                terminal_setcolor(0x0A); // Green
                terminal_putchar('\\');
                break;

            case ' ':
                terminal_putchar(' ');
                break;

            case 'n':
                terminal_putchar('\n');
                break;
        }
    }

    terminal_setcolor(0x07); // Light Grey
    printf("===============================================================================\n");
    terminal_setcolor(0x0F);
    printf("             ## BYOK: Forth machine, version: %s ##\n", VERSION);
    terminal_setcolor(0x07);
    printf("     This program (c) 2015 Richard Hull, published under the MIT License\n");
    printf("    To read the licence, type LICENSE <enter>. For help, type HELP <enter>\n");
    printf("===============================================================================\n");
}