fix memory leak

This commit is contained in:
reccetear 2017-04-25 16:29:42 +08:00
parent 0df8975597
commit d0183d7beb
9 changed files with 38 additions and 19 deletions

View File

@ -1,8 +1,10 @@
.globl _start
.type _start, @function
.globl _qemu
.type _qemu, @function
_start:
li $sp, 0x0001fffc
li $sp, 0x00017ffc
jal main
.globl _qemu

View File

@ -13,6 +13,7 @@ KERN=$(readlink -f ./build/kernel.o)
# generate COE
mips-linux-gnu-objdump -d $KERN > ./build/code.txt
mips-linux-gnu-objcopy -O binary $KERN ./build/kernel.bin
readelf -a $KERN > ./build/kernel.elf
python $DIR/scripts/bin2text.py ./build/kernel.bin ./build/ram.txt
python $DIR/scripts/gen_bram_coe.py ./build/kernel.bin ./build/app.coe

View File

@ -2,15 +2,23 @@
#define __NPC_H__
#define VMEM_ADDR ((void *)0xc0000000)
#define SCR_WIDTH 320
#define SCR_HEIGHT 240
#define SCR_WIDTH 40
#define SCR_HEIGHT 30
#define SCR_SIZE (SCR_WIDTH * SCR_HEIGHT)
//outside R G B(outside draw_p)
#define KEY_CODE_ADDR ((volatile unsigned int *)0xf0000000)
#define KEY_CODE (*KEY_CODE_ADDR)
#define HEAP_START 17fff
#define HEAP_END 1fffc
#define STACK_END ffff
#define STACK_START 17ffc
#define DATA_START 7fff
#define DATA_END fffc
#define CODE_START 0
#define CODE_END 7ffc
static inline u8 R(_Pixel p) { return p >> 16; }
static inline u8 G(_Pixel p) { return p >> 8; }
static inline u8 B(_Pixel p) { return p; }
//inside R G B(print draw_p)
static inline _Pixel pixel(u8 r, u8 g, u8 b) {
return (r << 16) | (g << 8) | b;
}
@ -18,7 +26,4 @@ void vga_init();
void serial_init();
void memory_init();
#define KEY_CODE_ADDR ((volatile unsigned int *)0xf0000000)
#define KEY_CODE (*KEY_CODE_ADDR)
#endif

View File

@ -1,8 +1,6 @@
#include <am.h>
#include <npc.h>
// TODO: implement these functions.
void _trm_init() {
serial_init();
memory_init();

View File

@ -2,8 +2,13 @@
#include <npc.h>
void memory_init(){
//0-7fff for code(32k)
//8000-ffff for data(32k)
//10000-17fff for stack(32k)
//18000-1ffff for heap(32k)
//probe a memory for heap
_heap.start = _heap.end;
_heap.start = (void *)0x18000;
_heap.end = (void *)0x1ffff;
}
void serial_init(){

5
apps/nop/README.md Normal file
View File

@ -0,0 +1,5 @@
# Nop
最简单的空程序用来判定当前kernel所占用内存空间大小
# issue
在保证内存空间的基础上,进行内存管理,合理分配堆栈,并使用脚本进行检查

6
apps/nop/src/main.c Normal file
View File

@ -0,0 +1,6 @@
#include <am.h>
#include <klib.h>
int main(){
return 0;
}

View File

@ -1,7 +1,7 @@
#include <am.h>
const int FPS = 30;
const int N = 96;
const int N = 20;
const bool scale = true;
static inline _Pixel pixel(u8 r, u8 g, u8 b) {
@ -11,6 +11,6 @@ static inline u8 R(_Pixel p) { return p >> 16; }
static inline u8 G(_Pixel p) { return p >> 8; }
static inline u8 B(_Pixel p) { return p; }
//extern _Pixel canvas[N][N];
extern _Pixel canvas[N][N];
void redraw();

View File

@ -2,12 +2,9 @@
#include <video.h>
#include <klib.h>
//_Pixel canvas[N][N];
//bool used[N][N];
//_Pixel fb[1024*768];
_Pixel **canvas = (_Pixel **)0x100000;
bool **used = (bool **)0x200000;
_Pixel *fb = (_Pixel *)0x300000;
_Pixel canvas[N][N];
bool used[N][N];
_Pixel fb[40 * 30];
void redraw() {
int w = _screen.width;