📄 os.c
字号:
/* * Roadrunner/pk * Copyright (C) 1989-2001 Cornfed Systems, Inc. * * The Roadrunner/pk operating system is free software; you can * redistribute and/or modify it under the terms of the GNU General * Public License, version 2, as published by the Free Software * Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the Free * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA * * More information about the Roadrunner/pk operating system of * which this file is a part is available on the World-Wide Web * at: http://www.cornfed.com. * */ #include <dev.h>#include <dev/cons.h>#include <dev/gd.h>#include <dev/kbd.h>#include <dev/serial.h> #include <dev/rd.h>#include <event.h>#include <fcntl.h>#include <fs.h>#include <fs/devfs.h>#include <fs/rrfs.h>#include <fs/sysfs.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <sys/boot.h>#include <sys/intr.h>#include <sys/mem.h>#include <sys/timer.h>#include <sys/utsname.h>#include <dev/lcd.h>void test1();void test2();void test3();void test4();void test1(){ int i; for(;;) { for(i=0;i<8000;i++) {
disable;
kprintf("\b\b\b\b\b\b%s","test1 "); enable;
} }}void test2(){ int i; for(;;) { for(i=0;i<16000;i++) { disable;
kprintf("\b\b\b\b\b\b%s","test2 "); enable;
} }}void test3(){ int i; for(;;) { for(i=0;i<16000;i++) { disable;
kprintf("\b\b\b\b\b\b%s","test3 "); enable;
} }}void test4(){ int i; for(;;) { for(i=0;i<8000;i++) { disable;
kprintf("\b\b\b\b\b\b%s","test4 "); enable;
} }}voidMain(){ struct utsname name; struct dev_ops devops; struct fsops fsops; fsops_t sysfsops, devfsops, rrfsops; fs_t sysfs, devfs, rrfs; file_t fdin = NULL, fdout = NULL, fderr = NULL; int result;
disable;
intr_init(); uname(&name); kprintf("%s %s.%s %s\n",name.sysname, name.version, name.release, COPYRIGHT); mem_init(); isrtab_init(); eventtab_init(); proc_sysinit(); timer_init(); time_init(); kbd_init(); devtab_init(); blkpool_init(PAGE_SIZE, BLKS); bufpool_init(BUFS); fstab_init(); /* Setup context for init process */ proctab[0].state = PS_RUN; strcpy(proctab[0].cwd, "/"); /* Init process is made currently executing process */ current = &(proctab[0]); kprintf("mem %d\n", (int) memsize); { region_t r; size_t freemem = 0; for (r = freelist; r != NULL; r = r->next) freemem += r->len; kprintf("avail %d\n", (int) freemem); } kprintf("kernel %d\n", (int) kernsize); /* Install keyboard device */ devops.init = kbd_init; devops.shut = kbd_shut; devops.ioctl = kbd_ioctl; devops.specific.char_ops.get = kbd_get; devops.specific.char_ops.put = NULL; dev_inst("kbd", DEV_TYPE_CHAR, &devops); /* Install console display device */ devops.init = cons_init; devops.shut = cons_shut; devops.ioctl = cons_ioctl; devops.specific.char_ops.get = NULL; devops.specific.char_ops.put = cons_put; dev_inst("cons", DEV_TYPE_CHAR, &devops);#if _SERIAL_PORTS /* Install primary serial device */ devops.init = s0_init; devops.shut = s0_shut; devops.ioctl = s0_ioctl; devops.specific.char_ops.get = s0_get; devops.specific.char_ops.put = s0_put; dev_inst("s0", DEV_TYPE_CHAR, &devops);#endif /* Install ram disk device */ devops.init = rd_init; devops.shut = rd_shut; devops.ioctl = rd_ioctl; devops.specific.blk_ops.read = rd_read; devops.specific.blk_ops.write = rd_write; dev_inst("rd", DEV_TYPE_BLK, &devops); dev_init("rd"); /* Install and initialize /sys file system */ strcpy(fsops.name, "sysfs"); fsops.init = sysfs_init; fsops.shut = sysfs_shut; fsops.mount = sysfs_mount; fsops.unmount = sysfs_unmount; fsops.open = sysfile_open; fsops.close = sysfile_close; fsops.ioctl = sysfile_ioctl; fsops.read = sysfile_read; fsops.write = sysfile_write; fsops.attr = sysfile_attr; fsops.readdir = sysfile_readdir; fsops.unlink = sysfile_unlink; sysfsops = fsops_inst(&fsops); fsops_init(sysfsops); /* Install and initialize device file system */ strcpy(fsops.name, "devfs"); fsops.init = devfs_init; fsops.shut = devfs_shut; fsops.mount = devfs_mount; fsops.unmount = devfs_unmount; fsops.open = devfile_open; fsops.close = devfile_close; fsops.ioctl = devfile_ioctl; fsops.read = devfile_read; fsops.write = devfile_write; fsops.attr = devfile_attr; fsops.readdir = devfile_readdir; fsops.unlink = devfile_unlink; devfsops = fsops_inst(&fsops); fsops_init(devfsops); /* Install and initialize rrfs file system */ strcpy(fsops.name, "rrfs"); fsops.init = rrfs_init; fsops.shut = rrfs_shut; fsops.mount = rrfs_mount; fsops.unmount = rrfs_unmount; fsops.open = rrfile_open; fsops.close = rrfile_close; fsops.ioctl = rrfile_ioctl; fsops.read = rrfile_read; fsops.write = rrfile_write; fsops.attr = rrfile_attr; fsops.readdir = rrfile_readdir; fsops.unlink = rrfile_unlink; rrfsops = fsops_inst(&fsops); fsops_init(rrfsops); /* Mount /sys file system */ fs_mount(sysfsops, "/sys", (-1), &sysfs); /* Mount device file system */ fs_mount(devfsops, "/dev", (-1), &devfs); /* Mount root file system */ fs_mount(rrfsops, "/", dev_open("rd"), &rrfs); /* Setup stdpaths for init process */ file_open("/dev/kbd", O_RDONLY, &fdin); file_open("/dev/cons", O_WRONLY, &fdout); file_open("/dev/cons", O_WRONLY, &fderr); proctab[0].fd[PFD_STDIN] = fdin->slot; proctab[0].fd[PFD_STDOUT] = fdout->slot; proctab[0].fd[PFD_STDERR] = fderr->slot; /* Start command shells for console */ //proc_exec("/abc/hello1", 1, (char**)"1234567890");
enable;
task_exec(test1); task_exec(test2); task_exec(test3); test4(); for (;;) { int c; //disable; //dev_init("s0"); //s0_get(&c); }; /* Not reached */}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -