incomplete refactor
This commit is contained in:
parent
48812662f0
commit
a6de532260
|
@ -0,0 +1,7 @@
|
|||
# MIPS32-NPC
|
||||
|
||||
AbstractMachine implementation for NJU-Personal-Computer (NPC).
|
||||
|
||||
## Memory Mappings
|
||||
|
||||
XXX - XXX: XXX
|
|
@ -1,6 +1,9 @@
|
|||
#ifndef __ARCH_LIB__
|
||||
#define __ARCH_LIB__
|
||||
|
||||
// These should not appear in the arch.h
|
||||
// See AM spec for more details.
|
||||
|
||||
#define VMEM ((char *)0xc0000000)
|
||||
#define KEY_CODE_ADDR ((volatile unsigned int *)0xf0000000)
|
||||
#define KEY_CODE (*KEY_CODE_ADDR)
|
||||
|
|
35
AM/spec.md
35
AM/spec.md
|
@ -4,41 +4,20 @@
|
|||
|
||||
* `_Area`代表一段连续的内存。
|
||||
|
||||
* ```
|
||||
typedef struct _Area {
|
||||
void *start, *end;
|
||||
} _Area;
|
||||
```
|
||||
|
||||
* `_Screen`描述系统初始化后的屏幕(后续可通过PCI总线设置显示控制器,则此设置不再有效)。
|
||||
|
||||
* ```
|
||||
typedef struct _Screen {
|
||||
int width, height;
|
||||
} _Screen;
|
||||
```
|
||||
|
||||
* 屏幕的像素颜色由32位整数`typedef u32 _Pixel;`确定,从高位到低位是00rrggbb,红绿蓝各8位。
|
||||
|
||||
* 按键代码由如下enum指定:
|
||||
* 按键代码由`_KEY_XXX`指定,其中`_KEY_NONE = 0`。
|
||||
|
||||
* ```
|
||||
enum {
|
||||
_KEY_NONE = 0,
|
||||
_KEY_UP, _KEY_DOWN, _KEY_LEFT, _KEY_RIGHT, ...
|
||||
};
|
||||
```
|
||||
* `_Protect`描述一个被保护的地址空间(`_area`),以及一个体系结构相关的指针(`ptr`)a。
|
||||
|
||||
* `_Protect`描述一个被保护的地址空间:
|
||||
## `arch.h`
|
||||
|
||||
* ```
|
||||
typedef struct _Protect {
|
||||
_Area area;
|
||||
void *ptr;
|
||||
} _Protect;
|
||||
```
|
||||
描述体系结构相关的信息,包括:
|
||||
|
||||
|
||||
* 整数类型`i8`, `u8`, `i16`, `u16`, `i32`, `u32`, `size_t`, `off_t`的定义。
|
||||
* `typedef struct _RegSet {}`代表所有体系结构寄存器。
|
||||
|
||||
## Turing Machine
|
||||
|
||||
|
@ -104,4 +83,4 @@ extern int _NR_CPU;
|
|||
#endif
|
||||
|
||||
|
||||
```
|
||||
```
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
// TODO: merge declarations into a single header.
|
||||
// TODO: klib should be compiled into one binary.
|
||||
|
||||
#ifndef __KLIB_H__
|
||||
#define __KLIB_H__
|
||||
|
||||
// We're expecting:
|
||||
// assert, printf, sprintf
|
||||
// memcpy, memset, strcpy, strlen, itoa, atoi, ...
|
||||
// kalloc, kree
|
||||
|
||||
#endif
|
|
@ -1,6 +1,8 @@
|
|||
#ifndef __TYPES_H__
|
||||
#define __TYPES_H__
|
||||
|
||||
// TODO: this is NOT expected to appear here.
|
||||
// types are arch-dependent.
|
||||
|
||||
typedef unsigned int uint32_t;
|
||||
typedef int int32_t;
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int main(){
|
||||
printf("now your are in user space!\n");
|
||||
printf("hello world!\n");
|
||||
while(1);
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue