void welcome() { tty_clear(); wstr_color(" |\\ /|( ____ \\( \\ ( ____ \\( ___ )( )( ____ \\\n", COLOR_RED); wstr_color(" | ) ( || ( \\/| ( | ( \\/| ( ) || () () || ( \\/\n", COLOR_RED); wstr_color(" | | _ | || (__ | | | | | | | || || || || (\\\n", COLOR_RED); wstr_color(" | |( )| || __) | | | | | | | || |(_)| || __)\\\n", COLOR_RED); wstr_color(" | || || || ( | | | | | | | || | | || (\\\n", COLOR_RED); wstr_color(" | () () || (____/\\| (____/\\| (____/\\| (___) || ) ( || (____/\\\n", COLOR_RED); wstr_color(" (_______)(_______/(_______/(_______/(_______)|/ \\|(_______/\n\n", COLOR_RED); wstr_color(" \\__ __/( ___ )\n", COLOR_YELLOW); wstr_color(" ) ( | ( ) |\n", COLOR_YELLOW); wstr_color(" | | | | | |\n", COLOR_YELLOW); wstr_color(" | | | | | |\n", COLOR_YELLOW); wstr_color(" | | | | | |\n", COLOR_YELLOW); wstr_color(" | | | (___) |\n", COLOR_YELLOW); wstr_color(" )_( (_______)\n\n", COLOR_YELLOW); wstr_color(" _______ _______ _________ _______ _ _______ _______ \n", COLOR_BLUE); wstr_color("( ____ )|\\ /|( ___ )\\__ __/( ___ )( ( /|( ___ )( ____ \\\\\n", COLOR_BLUE); wstr_color("| ( )|| ) ( || ( ) | ) ( | ( ) || \\ ( || ( ) || ( \\/\n", COLOR_BLUE); wstr_color("| (____)|| (___) || | | | | | | | | || \\ | || | | || (_____ \n", COLOR_BLUE); wstr_color("| _____)| ___ || | | | | | | | | || (\\ \\) || | | |(_____ )\n", COLOR_BLUE); wstr_color("| ( | ( ) || | | | | | | | | || | \\ || | | | ) |\n", COLOR_BLUE); wstr_color("| ) | ) ( || (___) | | | | (___) || ) \\ || (___) |/\\____) |\n", COLOR_BLUE); wstr_color("|/ |/ \\|(_______) )_( (_______)|/ )_)(_______)\\_______)\n", COLOR_BLUE); printk(" by Feraru Mihail"); getch(); tty_clear(); }
/* * Performs control operation on a tty device. */ PRIVATE int tty_ioctl(unsigned minor, unsigned cmd, unsigned arg) { int ret; UNUSED(minor); /* Parse command. */ switch (cmd) { /* Get tty settings. */ case TTY_GETS: ret = tty_gets(&tty, (struct termios *)arg); break; /* Clear console. */ case TTY_CLEAR: ret = tty_clear(&tty); break; /* Invalid operation. */ default: ret = -EINVAL; break; } return (ret); }
void tty_init() { tty_y = 0; tty_x = 0; tty_updatecursor(); tty_color = make_color(COLOR_LIGHT_GREY, COLOR_BLACK); tty_buffer = VGA_MEMORY; tty_clear(); }
/// Called from our bootstub /// \param mbd Virtual address of Grub multiboot info structure (*? bytes) /// \param magic Grub boot signature (0x1BADB002) (4 bytes) void arch_init(multiboot_info_t* mbd, unsigned int magic) { // Create the kernel info build string sprintf(kinfo.buildstring, "EOS (Built %s %s using GNU C version %s)", __DATE__, __TIME__, __VERSION__); // Low level hardware setup of the interrupt controller and system timer pic_init(); pit_init(100); asm ("sti"); // Clear screen tty_clear(); // Parse the command line kernel_parse_cmdline((char *)PHYS_VIRT(mbd->cmdline)); // Now safe to print to the kernel log printf("%s\n", kinfo.buildstring); kprintf(1, "arch_init(mbd: %08X, magic: %08X)\n", mbd, magic); // Read CPU information cpu_init(); // Read placement information kinfo.start = &_ld_kernel_start; kinfo.end = &_ld_kernel_end; kinfo.memory = mbd->mem_upper; // Read kernel elf headers elf_init_kernel(&mbd->u.elf_sec); // Read module information if (mbd->mods_count > 0) { kprintf(2, "found %d modules\n", mbd->mods_count); // Read multiboot module information multiboot_module_t *mod; mod = (void *)PHYS_VIRT(mbd->mods_addr); // Expand kernel end to include the loaded modules kinfo.end = (void *)PHYS_VIRT(mod[mbd->mods_count - 1].mod_end); // The first module is the initfs the rest are drivers if (mbd->mods_count > 1) arch_init_drivers(&mod[1], mbd->mods_count - 1); } // Start the memory manager mm_init(128 * 1024); dev_init(); kernel_init(); }
char *tty_rcall(uint64_t source, struct vfs_obj *file, const char *args) { char buffer[10]; if (!strcmp(args, "getfg")) { sprintf(buffer, "%d", getpid()); return strdup(buffer); } if (!strcmp(args, "clear")) { tty_clear(); tty->cursor = 0x0000; } return NULL; }
/**** start of autodetect code ***************************/ int is_it_is_it_huh(int port) { int j; tty_clear(port, 1, 0); ioctl(port, TIOCMGET, &j); if ((j & TIOCM_CTS) || (j & TIOCM_DSR)) return 0; tty_set(port, 1, 0); ioctl(port, TIOCMGET, &j); if ((!(j & TIOCM_CTS)) || (j & TIOCM_DSR)) return 0; return 1; }
int pinsys_init(void) { signal_length = (hw.code_length + (hw.code_length / BITS_COUNT) * 2) * 1000000 / 1200; if (!tty_create_lock(hw.device)) { logprintf(LOG_ERR, "could not create lock files"); return (0); } if ((hw.fd = open(hw.device, O_RDWR | O_NONBLOCK | O_NOCTTY)) < 0) { int detected; /* last character gets overwritten */ char auto_lirc_device[] = "/dev/ttyS_"; tty_delete_lock(); logprintf(LOG_WARNING, "could not open %s, autodetecting on /dev/ttyS[0-3]", hw.device); logperror(LOG_WARNING, "pinsys_init()"); /* it can also mean you compiled serial support as a module and it isn't inserted, but that's unlikely unless you're me. */ detected = autodetect(); if (detected == -1) { logprintf(LOG_ERR, "no device found on /dev/ttyS[0-3]"); tty_delete_lock(); return (0); } else { /* detected */ auto_lirc_device[9] = '0' + detected; hw.device = auto_lirc_device; if ((hw.fd = open(hw.device, O_RDWR | O_NONBLOCK | O_NOCTTY)) < 0) { /* unlikely, but hey. */ logprintf(LOG_ERR, "couldn't open autodetected device \"%s\"", hw.device); logperror(LOG_ERR, "pinsys_init()"); tty_delete_lock(); return (0); } } } if (!tty_reset(hw.fd)) { logprintf(LOG_ERR, "could not reset tty"); pinsys_deinit(); return (0); } if (!tty_setbaud(hw.fd, 1200)) { logprintf(LOG_ERR, "could not set baud rate"); pinsys_deinit(); return (0); } /* set RTS, clear DTR */ if (!tty_set(hw.fd, 1, 0) || !tty_clear(hw.fd, 0, 1)) { logprintf(LOG_ERR, "could not set modem lines (DTR/RTS)"); pinsys_deinit(); return (0); } /* I dunno, but when lircd starts may log `reading of byte 1 failed' I know that happened when testing, it's a zero byte. Problem is, flushing doesn't fix it. It's not fatal, it's an indication that it gets fixed. still... */ if (tcflush(hw.fd, TCIFLUSH) < 0) { logprintf(LOG_ERR, "could not flush input buffer"); pinsys_deinit(); return (0); } return (1); }
void shell(char *str) { if (!strcmp(str, "exit")) { panic("Exit.", __LINE__, __FILE__); } else if (!strcmp(str, "test")) { testing_shell(str); } else if (!strcmp(str, "time")) { print_time(); printk("\n"); } else if (!strcmp(str, "tick")) { printk("Tick: %d\n", get_tick()); } else if (!strcmp(str, "clock")) { printk("WARN: no clock yet"); } else if (!strcmp(str, "clear")) { tty_clear(); } else if (!strcmp(str, "reset-clock")) { hours = 0; minutes = 0; seconds = 0; } else if (!strcmp(str, "write")) { char *to_write = (char*) kmalloc(sizeof(char) * 30); size_t len = strlen("\nLet's write this...\n"); memcpy(to_write, "Let's write this...\n\0", len + 1); call(1, (uint32_t) to_write, (uint32_t) len, 0, 0, 0); } else if (!strcmp(str, "tty")) { ++tty_index; if (tty_index == 3) { tty_index = 0; } current_tty = ttys[tty_index]; printk("\n[SYS] Switched to tty %d.\n", tty_index); } else if (!strcmp(str, "reboot")) { printk("System will reboot..."); reboot(); } else if (!strcmp(str, "sys-info")) { printk("%s %s (%s) by %s.\nCopyright C 2015 %s.\nAll rights reserved.\n", OS_Name, Version, Relase_Date, Author, Author); } else if (!strcmp(str, "help")) { printk("After kernel boots up, user must enter user name and machine name. Now, a shell has started. Here user can use some commands:\n"); printk(" -> help -> display this page\n"); printk(" -> time -> display current time\n"); printk(" -> tick -> display current tick\n"); printk(" -> clock -> start a clock that can be stoped when ESC is pressed\n"); printk(" -> clear -> clear the screen\n"); printk(" -> reset->clock -> set clock to 0\n"); printk(" -> sys->info -> prints info about system\n"); printk(" -> test -> enter into testing shell that allows testing kernel functions\n"); printk(" -> exit -> close shell\n\n"); printk("Testing shell:\n"); printk(" Tests avabile in testing shell:\n"); printk(" -> exit -> close testing shell\n"); printk(" -> print-stdin -> print all data from standard input\n"); printk(" -> size -> print sizes of types, of kernel and RAM\n"); printk(" -> page-fault -> generate page fault\n"); printk(" -> address -> print addresses of all kernel variables and of some temporary\n"); printk(" -> alloc -> test kmalloc and kfree\n"); } else { printk("Command not found!\n"); } }