fix bugs
This commit is contained in:
parent
0819fb62d9
commit
be2a48a154
14
Makefile
14
Makefile
|
@ -1,6 +1,6 @@
|
|||
ifneq ($(MAKECMDGOALS), clean)
|
||||
ifeq ($(ARCH), )
|
||||
$(error "Usage: make [play|clean] ARCH=[mips32-npc|x86-linux|x86-qemu] APP=[hello,video,...]")
|
||||
$(error "Usage: make [play|clean] ARCH=[mips32-npc|x86-linux|x86-qemu] APP=[hello|video|...]")
|
||||
endif
|
||||
endif
|
||||
|
||||
|
@ -34,15 +34,15 @@ APP_DEP = $(addsuffix .d, $(basename $(APP_SRC)))
|
|||
|
||||
# Klib archive
|
||||
KLIB = ./build/libkern-$(ARCH).a
|
||||
KLIB_SRC = $(shell find -L ./klib/src -name "*.c" -o -name "*.cpp" -o -name "*.S")
|
||||
KLIB_OBJ = $(addsuffix .o, $(basename $(APP_SRC)))
|
||||
KLIB_DEP = $(addsuffix .d, $(basename $(APP_SRC)))
|
||||
KLIB_SRC = $(shell find -L ./klib/ -name "*.c" -o -name "*.cpp" -o -name "*.S")
|
||||
KLIB_OBJ = $(addsuffix .o, $(basename $(KLIB_SRC)))
|
||||
KLIB_DEP = $(addsuffix .d, $(basename $(KLIB_SRC)))
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
# Basic compilation flags
|
||||
CFLAGS += -std=gnu99 -I ./am/ -I./$(AM_PATH)/include -I./$(APP_PATH)/include -O2 -MD -Wall -Werror -ggdb
|
||||
CXXFLAGS += -std=c++11 -I ./am/ -I./$(AM_PATH)/include -I./$(APP_PATH)/include -O2 -MD -Wall -Werror -ggdb
|
||||
CFLAGS += -std=gnu99 -I ./am/ -I./$(AM_PATH)/include -I./klib -I./$(APP_PATH)/include -O2 -MD -Wall -Werror -ggdb
|
||||
CXXFLAGS += -std=c++11 -I ./am/ -I./$(AM_PATH)/include -I./klib -I./$(APP_PATH)/include -O2 -MD -Wall -Werror -ggdb
|
||||
ASFLAGS += -I ./am/ -I./$(AM_PATH)/include -I./$(APP_PATH)/include -MD
|
||||
|
||||
# Arch-dependent compilation flags
|
||||
|
@ -81,6 +81,8 @@ $(APP_LIB): $(APP_OBJ)
|
|||
ar rcs $(APP_LIB) $(APP_OBJ)
|
||||
-include $(APP_DEP)
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
.PHONY: play clean
|
||||
|
||||
play: $(AM_LIB) $(DEST)
|
||||
|
|
2
am/am.h
2
am/am.h
|
@ -86,7 +86,7 @@ void _pte_init(void*(*palloc)(), void (*pfree)(void*));
|
|||
void _protect(_Protect *p);
|
||||
void _release(_Protect *p);
|
||||
void _map(_Protect *p, void *va, void *pa);
|
||||
void _ummap(_Protect *p, void *va);
|
||||
void _unmap(_Protect *p, void *va);
|
||||
void _switch(_Protect *p);
|
||||
_RegSet *_umake(_Area ustack, _Area kstack, void *entry, int argc, char **argv);
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include <am.h>
|
||||
#include <video.h>
|
||||
#include <klib.h>
|
||||
|
||||
_Pixel canvas[N][N];
|
||||
bool used[N][N];
|
||||
|
@ -66,7 +67,6 @@ int main() {
|
|||
_trm_init();
|
||||
_ioe_init();
|
||||
|
||||
|
||||
ulong last = 0;
|
||||
|
||||
while (true) {
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
// the implementation goes here
|
||||
// may need other files
|
12
klib/klib.h
12
klib/klib.h
|
@ -5,9 +5,21 @@
|
|||
#ifndef __KLIB_H__
|
||||
#define __KLIB_H__
|
||||
|
||||
#include <am.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// We're expecting:
|
||||
// assert, printf, sprintf
|
||||
// memcpy, memset, strcpy, strlen, itoa, atoi, ...
|
||||
// kalloc, kree
|
||||
|
||||
size_t strlen(const char *s);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
#include <klib.h>
|
||||
|
||||
size_t strlen(const char *s) {
|
||||
size_t sz = 0;
|
||||
for (; *s; s ++) {
|
||||
sz ++;
|
||||
}
|
||||
return sz;
|
||||
}
|
Loading…
Reference in New Issue