Skip to content

310554049 LAB8 #122

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: 310554049
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

| Github Account | Student ID | Name |
|----------------|------------|---------------|
| hellcwang | 310554049 | Chia-Wei Wang |
| | 310554049 | |

## Requirements

Expand Down
2 changes: 1 addition & 1 deletion lab8/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ all: clean kernel8.img initramfs.cpio
#initramfs.cpio: initramfs
# cd initramfs; find . -print -depth | cpio -H newc -o > $@; mv $@ ..

initramfs.cpio: vfs1.img
initramfs.cpio: vfs2.img
ls $^ | cpio -H newc -o > $@

$(OBJ_DIR)/%.o: $(SRC_DIR)/%.S
Expand Down
3 changes: 2 additions & 1 deletion lab8/config.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
initramfs initramfs.cpio 0x8000000
initramfs ramfs.cpi 0x8000000
device_tree=dt.dtb
24 changes: 12 additions & 12 deletions lab8/include/fatfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,24 @@ typedef struct {
int size;
size_t Eof;
void *dirs;
void *data;
uint32_t data; // The sector of the data
} FsAttr;

// For the directory
typedef struct {
char name[8]; // SFN care tof the first byte
char ext[3]; // Extension pad with " "
uint8_t attr; // File attribute Normal -> 0
uint8_t attr2; // default: 0
uint8_t createTimeMs; // ms of the createTime
uint16_t createTime; // 15:13 -> Hours, 10:5 -> Min, 4:0 -> seconds
uint16_t createTimeDate; // 15:13 -> Year, 10:5 -> Mon, 4:0 -> Day
char name[8]; // SFN care tof the first byte
char ext[3]; // Extension pad with " "
uint8_t attr; // File attribute Normal -> 0
uint8_t attr2; // default: 0
uint8_t createTimeMs; // ms of the createTime
uint16_t createTime; // 15:13 -> Hours, 10:5 -> Min, 4:0 -> seconds
uint16_t createTimeDate; // 15:13 -> Year, 10:5 -> Mon, 4:0 -> Day
uint16_t ownerID;
uint16_t highAddr; // High two bytes of first cluster
uint16_t highAddr; // High two bytes of first cluster
uint16_t modifiedTime;
uint16_t modifiedDate;
uint16_t lowAddr; // Low two bytes of first cluster
uint32_t size; // Total size of file
uint16_t lowAddr; // Low two bytes of first cluster
uint32_t size; // Total size of file
} Entry;

int fatfs_init(struct filesystem *fs, struct mount *m);
Expand All @@ -49,6 +49,6 @@ int fatfs_read(struct file *f, void *buf, size_t len);
int fatfs_write(struct file *f, const void *buf, size_t len);
int fatfs_open(struct vnode *, struct file **target);
int fatfs_close(struct file *f);

void fatfs_sync();

#endif
10 changes: 5 additions & 5 deletions lab8/include/framefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
#include "uart.h"
#include "vfs.h"

struct framebuffer_info{
unsigned int width;
unsigned int height;
unsigned int pitch;
unsigned int isrgb;
struct framebuffer_info {
unsigned int width;
unsigned int height;
unsigned int pitch;
unsigned int isrgb;
};

int framefs_init(struct filesystem *fs, struct mount *m);
Expand Down
1 change: 0 additions & 1 deletion lab8/include/ramfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,4 @@ int ramfs_write(struct file *f, const void *buf, size_t len);
int ramfs_open(struct vnode *, struct file **target);
int ramfs_close(struct file *f);


#endif
4 changes: 2 additions & 2 deletions lab8/include/sd.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef SD_H
#define SD_H

void readblock(int, void*);
void writeblock(int, void*);
void readblock(int, void *);
void writeblock(int, void *);
void sd_init();
#endif
3 changes: 2 additions & 1 deletion lab8/include/syscall.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ int sys_mount(const char *src, const char *target, const char *filesystem,
unsigned long, const void *);
int sys_chdir(const char *path);
long sys_lseek64(int fd, long offset, int whence);
int sys_ioctl(int fd, unsigned long request, void* fb_info);
int sys_ioctl(int fd, unsigned long request, void *fb_info);
void sys_sync();

#endif // SYSCALL_H
32 changes: 19 additions & 13 deletions lab8/include/vfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,33 @@ typedef enum {

/* THis is the INODE*/
struct vnode {
struct vnode *parent; // Parent DIR
struct mount *mount; // The mount node of the FS
struct vnode *parent; // Parent DIR
struct mount *mount; // The mount node of the FS
struct vnode_operations *v_ops; // Vnode operations
struct file_operations *f_ops; // File operations
char name[16]; // Name of the node.
FsTy type; // Type of the vnode
void *internal; // The for each file defined
struct file_operations *f_ops; // File operations
char name[16]; // Name of the node.
FsTy type; // Type of the vnode
void *internal; // The for each file defined
};

/* Mount Node of the FS*/
struct mount {
struct vnode *root; // The root of this fs
struct filesysytem *system; // Point to the file system
struct vnode *root; // The root of this fs
struct filesysytem *system; // Point to the file system
};

/* Opening a file need to do following things. * 1. Allocat a file strucure.
* * 2. Copy the member operation from dentry (INODE) A place the file
* descriptor table for the process.
*/
struct file {
struct vnode *vnode; // The original vnode of file
size_t f_pos; // Current position of the file
size_t Eof; // End of the FILE
struct vnode *vnode; // The original vnode of file
size_t f_pos; // Current position of the file
size_t Eof; // End of the FILE
struct file_operations *f_ops;
int flags;
void *data; // The data of this file
void *data; // The data of this file
int dirty;
};

/* This structure contain the filesystem name such as Ext3
Expand Down Expand Up @@ -66,6 +67,12 @@ struct file_operations {
int (*close)(struct file *);
};

typedef struct FIle_list {
struct FIle_list *prev;
struct FIle_list *next;
struct file *f;
} file_list;

// struct mount* rootfs;

/* From linux vfs.rst It sys.
Expand All @@ -87,7 +94,6 @@ int vfs_mount(const char *target, const char *filesystem);
*/
int vfs_lookup(const char *pathname, struct vnode **target, struct vnode *root);


#define O_CREAT 0b0100
#define SEEK_SET 0

Expand Down
Loading