Skip to content

Commit

Permalink
完成了必答题
Browse files Browse the repository at this point in the history
  • Loading branch information
cs-qyzhang committed Dec 12, 2019
1 parent 5844622 commit 0156992
Show file tree
Hide file tree
Showing 19 changed files with 359 additions and 13 deletions.
10 changes: 5 additions & 5 deletions nanos-lite/src/proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ void hello_fun(void *arg) {

void run_proc(PCB *pcb) {
extern void _urun(_AddressSpace *as, void (*entry)());
current = pcb;
_urun(&pcb->as, (void (*)())pcb->cp->eip);
}

Expand All @@ -28,10 +29,7 @@ void init_proc() {
extern void context_uload(PCB *pcb, const char *filename);

//context_kload(&pcb[0], (void *)hello_fun);

//switch_boot_pcb();
current = &pcb[0];
fg_pcb = &pcb[1];

Log("Initializing processes...");

Expand All @@ -41,12 +39,14 @@ void init_proc() {
context_uload(&pcb[1], "/bin/pal");
context_uload(&pcb[2], "/bin/pal");
context_uload(&pcb[3], "/bin/pal");
run_proc(&pcb[0]);

fg_pcb = &pcb[1];
run_proc(&pcb[1]);
}

_Context* schedule(_Context *prev) {
static uint32_t cnt = 0;
const int fg_nice = 2000;
const int fg_nice = 50;

current->cp = prev;
current = (cnt++ % fg_nice) ? fg_pcb : &pcb[0];
Expand Down
1 change: 1 addition & 0 deletions navy-apps/apps/init/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ struct MenuItem {
{"events", "/bin/events", NULL},
{"hello", "/bin/hello", NULL},
{"text", "/bin/text", NULL},
{"am-typing", "/bin/typing-am", NULL},
};

#define nitems (sizeof(items) / sizeof(items[0]))
Expand Down
2 changes: 1 addition & 1 deletion navy-apps/apps/litenes/src/fce.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ void _ioe_init();
int main(int argc, char *argv[]) {
const char *fname;
if (argc < 2) {
fname = "/share/games/nes/kungfu.nes";
fname = "/share/games/nes/mario.nes";
fprintf(stderr, "No ROM specified. Deafult to %s\n", fname);
} else {
fname = argv[1];
Expand Down
32 changes: 32 additions & 0 deletions nexus-am/am/src/navy/ioe.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include <am.h>
#include <amdev.h>

void __am_vga_init();
void __am_timer_init();

int _ioe_init() {
__am_vga_init();
__am_timer_init();
return 0;
}

size_t __am_timer_read(uintptr_t reg, void *buf, size_t size);
size_t __am_video_read(uintptr_t reg, void *buf, size_t size);
size_t __am_video_write(uintptr_t reg, void *buf, size_t size);
size_t __am_input_read(uintptr_t reg, void *buf, size_t size);

size_t _io_read(uint32_t dev, uintptr_t reg, void *buf, size_t size) {
switch (dev) {
case _DEV_INPUT: return __am_input_read(reg, buf, size);
case _DEV_TIMER: return __am_timer_read(reg, buf, size);
case _DEV_VIDEO: return __am_video_read(reg, buf, size);
}
return 0;
}

size_t _io_write(uint32_t dev, uintptr_t reg, void *buf, size_t size) {
switch (dev) {
case _DEV_VIDEO: return __am_video_write(reg, buf, size);
}
return 0;
}
34 changes: 31 additions & 3 deletions nexus-am/am/src/navy/trm.c
Original file line number Diff line number Diff line change
@@ -1,13 +1,41 @@
#include <am.h>
#include <stdio.h>

_Area _heap = {};
/*_Area _heap = {};*/

void _trm_init() {
}
/*void _trm_init() {*/
/*}*/

/*void _putc(char ch) {*/
/*}*/

/*void _halt(int code) {*/
/*while (1);*/
/*}*/
extern char _heap_start;
extern char _heap_end;
int main(const char *args);

_Area _heap = {
.start = &_heap_start,
.end = &_heap_end,
};

void _putc(char ch) {
putchar(ch);
}

void _halt(int code) {
extern void _exit(int status);
_exit(code);

// should not reach here
while (1);
}

void _trm_init() {
extern const char _start;
const char *mainargs = &_start - 0x100000;
int ret = main(mainargs);
_halt(ret);
}
5 changes: 5 additions & 0 deletions nexus-am/apps/coremark/Makefile.navy
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
NAME = coremark-am
APP = /home/qyzhang/Projects/ics-2019/nexus-am/apps/coremark/build/coremark-x86-navy
OBJS = /home/qyzhang/Projects/ics-2019/nexus-am/apps/coremark/build/x86-navy//./src/core_list_join.o /home/qyzhang/Projects/ics-2019/nexus-am/apps/coremark/build/x86-navy//./src/core_util.o /home/qyzhang/Projects/ics-2019/nexus-am/apps/coremark/build/x86-navy//./src/core_matrix.o /home/qyzhang/Projects/ics-2019/nexus-am/apps/coremark/build/x86-navy//./src/core_state.o /home/qyzhang/Projects/ics-2019/nexus-am/apps/coremark/build/x86-navy//./src/core_portme.o /home/qyzhang/Projects/ics-2019/nexus-am/apps/coremark/build/x86-navy//./src/core_main.o /home/qyzhang/Projects/ics-2019/nexus-am/am/build/am-x86-navy.a /home/qyzhang/Projects/ics-2019/nexus-am/libs/klib/build/klib-x86-navy.a
LIBS += libndl
include /home/qyzhang/Projects/ics-2019/navy-apps/Makefile.app
5 changes: 5 additions & 0 deletions nexus-am/apps/dhrystone/Makefile.navy
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
NAME = dhrystone-am
APP = /home/qyzhang/Projects/ics-2019/nexus-am/apps/dhrystone/build/dhrystone-x86-navy
OBJS = /home/qyzhang/Projects/ics-2019/nexus-am/apps/dhrystone/build/x86-navy//dry.o /home/qyzhang/Projects/ics-2019/nexus-am/am/build/am-x86-navy.a /home/qyzhang/Projects/ics-2019/nexus-am/libs/klib/build/klib-x86-navy.a
LIBS += libndl
include /home/qyzhang/Projects/ics-2019/navy-apps/Makefile.app
5 changes: 5 additions & 0 deletions nexus-am/apps/litenes/Makefile.navy
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
NAME = litenes-am
APP = /home/qyzhang/Projects/ics-2019/nexus-am/apps/litenes/build/litenes-x86-navy
OBJS = /home/qyzhang/Projects/ics-2019/nexus-am/apps/litenes/build/x86-navy//./src/mmc.o /home/qyzhang/Projects/ics-2019/nexus-am/apps/litenes/build/x86-navy//./src/memory.o /home/qyzhang/Projects/ics-2019/nexus-am/apps/litenes/build/x86-navy//./src/roms/gen/f1.o /home/qyzhang/Projects/ics-2019/nexus-am/apps/litenes/build/x86-navy//./src/roms/gen/sky_destroyer.o /home/qyzhang/Projects/ics-2019/nexus-am/apps/litenes/build/x86-navy//./src/roms/gen/spartanx.o /home/qyzhang/Projects/ics-2019/nexus-am/apps/litenes/build/x86-navy//./src/roms/gen/kungfu.o /home/qyzhang/Projects/ics-2019/nexus-am/apps/litenes/build/x86-navy//./src/roms/gen/stargate.o /home/qyzhang/Projects/ics-2019/nexus-am/apps/litenes/build/x86-navy//./src/roms/gen/karateka.o /home/qyzhang/Projects/ics-2019/nexus-am/apps/litenes/build/x86-navy//./src/roms/gen/mario.o /home/qyzhang/Projects/ics-2019/nexus-am/apps/litenes/build/x86-navy//./src/roms/gen/pacman.o /home/qyzhang/Projects/ics-2019/nexus-am/apps/litenes/build/x86-navy//./src/roms/gen/bomberman.o /home/qyzhang/Projects/ics-2019/nexus-am/apps/litenes/build/x86-navy//./src/roms/gen/starforce.o /home/qyzhang/Projects/ics-2019/nexus-am/apps/litenes/build/x86-navy//./src/roms/gen/tetris.o /home/qyzhang/Projects/ics-2019/nexus-am/apps/litenes/build/x86-navy//./src/roms/gen/lunar_pool.o /home/qyzhang/Projects/ics-2019/nexus-am/apps/litenes/build/x86-navy//./src/roms/gen/exerion.o /home/qyzhang/Projects/ics-2019/nexus-am/apps/litenes/build/x86-navy//./src/roms/gen/pinball.o /home/qyzhang/Projects/ics-2019/nexus-am/apps/litenes/build/x86-navy//./src/roms/gen/balloon.o /home/qyzhang/Projects/ics-2019/nexus-am/apps/litenes/build/x86-navy//./src/ppu.o /home/qyzhang/Projects/ics-2019/nexus-am/apps/litenes/build/x86-navy//./src/cpu.o /home/qyzhang/Projects/ics-2019/nexus-am/apps/litenes/build/x86-navy//./src/psg.o /home/qyzhang/Projects/ics-2019/nexus-am/apps/litenes/build/x86-navy//./src/common.o /home/qyzhang/Projects/ics-2019/nexus-am/apps/litenes/build/x86-navy//./src/cpu-addressing.o /home/qyzhang/Projects/ics-2019/nexus-am/apps/litenes/build/x86-navy//./src/fce.o /home/qyzhang/Projects/ics-2019/nexus-am/am/build/am-x86-navy.a /home/qyzhang/Projects/ics-2019/nexus-am/libs/klib/build/klib-x86-navy.a
LIBS += libndl
include /home/qyzhang/Projects/ics-2019/navy-apps/Makefile.app
5 changes: 5 additions & 0 deletions nexus-am/apps/microbench/Makefile.navy
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
NAME = microbench-am
APP = /home/qyzhang/Projects/ics-2019/nexus-am/apps/microbench/build/microbench-x86-navy
OBJS = /home/qyzhang/Projects/ics-2019/nexus-am/apps/microbench/build/x86-navy//./src/sieve/sieve.o /home/qyzhang/Projects/ics-2019/nexus-am/apps/microbench/build/x86-navy//./src/queen/queen.o /home/qyzhang/Projects/ics-2019/nexus-am/apps/microbench/build/x86-navy//./src/bf/bf.o /home/qyzhang/Projects/ics-2019/nexus-am/apps/microbench/build/x86-navy//./src/ssort/ssort.o /home/qyzhang/Projects/ics-2019/nexus-am/apps/microbench/build/x86-navy//./src/dinic/dinic.o /home/qyzhang/Projects/ics-2019/nexus-am/apps/microbench/build/x86-navy//./src/lzip/lzip.o /home/qyzhang/Projects/ics-2019/nexus-am/apps/microbench/build/x86-navy//./src/lzip/quicklz.o /home/qyzhang/Projects/ics-2019/nexus-am/apps/microbench/build/x86-navy//./src/md5/md5.o /home/qyzhang/Projects/ics-2019/nexus-am/apps/microbench/build/x86-navy//./src/fib/fib.o /home/qyzhang/Projects/ics-2019/nexus-am/apps/microbench/build/x86-navy//./src/qsort/qsort.o /home/qyzhang/Projects/ics-2019/nexus-am/apps/microbench/build/x86-navy//./src/bench.o /home/qyzhang/Projects/ics-2019/nexus-am/apps/microbench/build/x86-navy//./src/15pz/15pz.o /home/qyzhang/Projects/ics-2019/nexus-am/am/build/am-x86-navy.a /home/qyzhang/Projects/ics-2019/nexus-am/libs/klib/build/klib-x86-navy.a
LIBS += libndl
include /home/qyzhang/Projects/ics-2019/navy-apps/Makefile.app
5 changes: 5 additions & 0 deletions nexus-am/apps/slider/Makefile.navy
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
NAME = slider-am
APP = /home/qyzhang/Projects/ics-2019/nexus-am/apps/slider/build/slider-x86-navy
OBJS = /home/qyzhang/Projects/ics-2019/nexus-am/apps/slider/build/x86-navy//main.o /home/qyzhang/Projects/ics-2019/nexus-am/apps/slider/build/x86-navy//image.o /home/qyzhang/Projects/ics-2019/nexus-am/am/build/am-x86-navy.a /home/qyzhang/Projects/ics-2019/nexus-am/libs/klib/build/klib-x86-navy.a
LIBS += libndl
include /home/qyzhang/Projects/ics-2019/navy-apps/Makefile.app
5 changes: 5 additions & 0 deletions nexus-am/apps/typing/Makefile.navy
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
NAME = typing-am
APP = /home/qyzhang/Projects/ics-2019/nexus-am/apps/typing/build/typing-x86-navy
OBJS = /home/qyzhang/Projects/ics-2019/nexus-am/apps/typing/build/x86-navy//game.o /home/qyzhang/Projects/ics-2019/nexus-am/apps/typing/build/x86-navy//draw.o /home/qyzhang/Projects/ics-2019/nexus-am/apps/typing/build/x86-navy//font.o /home/qyzhang/Projects/ics-2019/nexus-am/apps/typing/build/x86-navy//keyboard.o /home/qyzhang/Projects/ics-2019/nexus-am/am/build/am-x86-navy.a /home/qyzhang/Projects/ics-2019/nexus-am/libs/klib/build/klib-x86-navy.a
LIBS += libndl
include /home/qyzhang/Projects/ics-2019/navy-apps/Makefile.app
4 changes: 2 additions & 2 deletions report/environment.tex
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
\chapter{开发环境}
\section{硬件配置}

\hustfigure{figure/neofetch.png}{\texttt{neofetch}命令输出}{fig:neofetch}

\section{软件配置}
\begin{luacode}
env = require("sysenv")
local cmds = {"gcc", "nvim", "ld", "python"}
local cmds = {"gcc", "nvim", "python"}
env.print_sysversion(cmds)
\end{luacode}
Loading

0 comments on commit 0156992

Please sign in to comment.