Skip to content
Snippets Groups Projects
Commit 7ac2068f authored by abinade2's avatar abinade2
Browse files

added more comments

parent 7546e54a
No related branches found
No related tags found
No related merge requests found
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
/* /*
*init_filesys *init_filesys
* *
*DISCRIPTION: initialize file system *DESCRIPTION: initialize file system
*INPUT: filesys_start -- the starting address of the file system *INPUT: filesys_start -- the starting address of the file system
*RETURN: void *RETURN: void
*/ */
...@@ -22,7 +22,7 @@ void init_filesys(const uint32_t filesys_start){ ...@@ -22,7 +22,7 @@ void init_filesys(const uint32_t filesys_start){
/* /*
*read_dentry_by_name *read_dentry_by_name
* *
*DISCRIPTION: this function fill in the dentry_t block passed as their second argument with the file name, file *DESCRIPTION: this function fill in the dentry_t block passed as their second argument with the file name, file
* type, and inode number for the file. * type, and inode number for the file.
*INPUT: fname -- the name of the file, might be > 32 char *INPUT: fname -- the name of the file, might be > 32 char
* dentry -- directory entry * dentry -- directory entry
...@@ -51,7 +51,7 @@ int32_t read_dentry_by_name(const uint8_t* fname, dentry_t* dentry){ ...@@ -51,7 +51,7 @@ int32_t read_dentry_by_name(const uint8_t* fname, dentry_t* dentry){
/* /*
*read_dentry_by_index *read_dentry_by_index
* *
*DISCRIPTION: this function fill in the dentry t block passed as their second argument with the file name, file *DESCRIPTION: this function fill in the dentry t block passed as their second argument with the file name, file
* type, and inode number for the file, then return 0. * type, and inode number for the file, then return 0.
*INPUT: index -- index into the dentry block in boot block *INPUT: index -- index into the dentry block in boot block
* dentry -- directory entry to be filled in * dentry -- directory entry to be filled in
...@@ -71,7 +71,7 @@ int32_t read_dentry_by_index(uint32_t index, dentry_t* dentry){ ...@@ -71,7 +71,7 @@ int32_t read_dentry_by_index(uint32_t index, dentry_t* dentry){
/* /*
*read_data *read_data
* *
*DISCRIPTION: this function works much like the read system call, reading up to *DESCRIPTION: this function works much like the read system call, reading up to
* length bytes starting from position offset in the file with inode number * length bytes starting from position offset in the file with inode number
* inode and returning the number of bytes read and placed in the buffer. * inode and returning the number of bytes read and placed in the buffer.
* *
...@@ -125,7 +125,7 @@ int32_t read_data(uint32_t inode, uint32_t offset, uint8_t* buf, uint32_t length ...@@ -125,7 +125,7 @@ int32_t read_data(uint32_t inode, uint32_t offset, uint8_t* buf, uint32_t length
/* /*
*Read File *Read File
* *
*DISCRIPTION: *DESCRIPTION: reads the number of bytes data into buffer
*INPUT: fd -- file discriptor *INPUT: fd -- file discriptor
* buf -- buffer that store the file * buf -- buffer that store the file
* nbytes -- the number of bytes that need to read * nbytes -- the number of bytes that need to read
...@@ -150,7 +150,7 @@ int32_t read_file(int32_t fd_n, void* buf, int32_t nbytes){ ...@@ -150,7 +150,7 @@ int32_t read_file(int32_t fd_n, void* buf, int32_t nbytes){
/* /*
*Write File *Write File
* *
*DISCRIPTION: *DESCRIPTION: returns -1 (do nothing since it is read-only)
*INPUT: fd -- file discriptor *INPUT: fd -- file discriptor
* buf -- buffer that store the file * buf -- buffer that store the file
* nbytes -- the number of bytes that need to read * nbytes -- the number of bytes that need to read
...@@ -163,19 +163,18 @@ int32_t write_file(int32_t fd, const void* buf, int32_t nbytes){ ...@@ -163,19 +163,18 @@ int32_t write_file(int32_t fd, const void* buf, int32_t nbytes){
/* /*
*Open File *Open File
* *
*DISCRIPTION: use filename to fill in dentry *DESCRIPTION: use filename to fill in dentry
*INPUT: filename -- file name *INPUT: filename -- file name
*RETURN: 0 success, -1 fail *RETURN: 0 success, -1 fail
*/ */
int32_t open_file(const uint8_t* filename){ int32_t open_file(const uint8_t* filename){
return 0; return 0;
// return (read_dentry_by_name(filename, &global_dentry));
} }
/* /*
*Close File *Close File
* *
*DISCRIPTION: *DESCRIPTION: do nothing
*INPUT: fd -- file discriptor *INPUT: fd -- file discriptor
*RETURN:0 success, -1 fail *RETURN:0 success, -1 fail
*/ */
...@@ -188,7 +187,7 @@ int32_t close_file(int32_t fd){ ...@@ -188,7 +187,7 @@ int32_t close_file(int32_t fd){
/* /*
*Read Directory *Read Directory
* *
*DISCRIPTION: *DESCRIPTION: read next file in current directory
*INPUT: fd -- file discriptor *INPUT: fd -- file discriptor
* buf -- buffer that store the file * buf -- buffer that store the file
* nbytes -- the number of bytes that need to read * nbytes -- the number of bytes that need to read
...@@ -221,7 +220,7 @@ int32_t read_dir(int32_t fd_n, void* buf, int32_t nbytes){ ...@@ -221,7 +220,7 @@ int32_t read_dir(int32_t fd_n, void* buf, int32_t nbytes){
/* /*
*Write Directory *Write Directory
* *
*DISCRIPTION: *DESCRIPTION: does nothing
*INPUT: fd -- file discriptor *INPUT: fd -- file discriptor
* buf -- buffer that store the file * buf -- buffer that store the file
* nbytes -- the number of bytes that need to read * nbytes -- the number of bytes that need to read
...@@ -234,19 +233,18 @@ int32_t write_dir(int32_t fd, const void* buf, int32_t nbytes){ ...@@ -234,19 +233,18 @@ int32_t write_dir(int32_t fd, const void* buf, int32_t nbytes){
/* /*
*Open Directory *Open Directory
* *
*DISCRIPTION: *DESCRIPTION: does nothing
*INPUT: filename -- file name *INPUT: filename -- file name
*RETURN:0 success, -1 fail *RETURN:0 success, -1 fail
*/ */
int32_t open_dir(const uint8_t* filename){ int32_t open_dir(const uint8_t* filename){
return 0; return 0;
// return (read_dentry_by_name(filename, &global_dentry));
} }
/* /*
*Close Directory *Close Directory
* *
*DISCRIPTION: *DESCRIPTION: does nothing
*INPUT: fd -- file discriptor *INPUT: fd -- file discriptor
*RETURN:0 success, -1 fail *RETURN:0 success, -1 fail
*/ */
......
...@@ -147,7 +147,7 @@ int32_t execute(const uint8_t* command) ...@@ -147,7 +147,7 @@ int32_t execute(const uint8_t* command)
total_prog_count++; total_prog_count++;
terminal[running_terminal].terminal_prog_count++; terminal[running_terminal].terminal_prog_count++;
//get entry point from bytes 24 to 27 in exe file //get entry point from bytes 24 to 27 in each exe file
read_data( dentry.inode_index, ENTRY_POINT, buf, 4); read_data( dentry.inode_index, ENTRY_POINT, buf, 4);
entry_point = *((uint32_t*)buf); entry_point = *((uint32_t*)buf);
...@@ -158,20 +158,20 @@ int32_t execute(const uint8_t* command) ...@@ -158,20 +158,20 @@ int32_t execute(const uint8_t* command)
//-------------------- 4: User-level Program Loader ------------------------ //-------------------- 4: User-level Program Loader ------------------------
read_data( dentry.inode_index, 0, (uint8_t*)PROGRAM_START, get_file_size(dentry.inode_index));//load 1Mb // loading executable
read_data( dentry.inode_index, 0, (uint8_t*)PROGRAM_START, get_file_size(dentry.inode_index));
//-------------------- 5: set up pcb---------------------------------------- //-------------------- 5: set up pcb----------------------------------------
uint32_t temp_esp, temp_ebp; uint32_t temp_esp, temp_ebp;
// checks if we're running shell for first time on terminal (if so, gets ebp and esp from scheduler)
if(terminal[running_terminal].pcb != NULL && terminal[running_terminal].pcb->scheduler_flag) if(terminal[running_terminal].pcb != NULL && terminal[running_terminal].pcb->scheduler_flag)
{ {
temp_esp = terminal[running_terminal].pcb->current_esp; temp_esp = terminal[running_terminal].pcb->current_esp;
temp_ebp = terminal[running_terminal].pcb->current_ebp; temp_ebp = terminal[running_terminal].pcb->current_ebp;
terminal[running_terminal].pcb->scheduler_flag = 0; terminal[running_terminal].pcb->scheduler_flag = 0;
} }else{
else
{
temp_esp = 0; temp_esp = 0;
temp_ebp = 0; temp_ebp = 0;
} }
...@@ -194,6 +194,7 @@ int32_t execute(const uint8_t* command) ...@@ -194,6 +194,7 @@ int32_t execute(const uint8_t* command)
terminal[running_terminal].pcb = pcb_ptr; terminal[running_terminal].pcb = pcb_ptr;
// checks if command is shell
if (strncmp("shell", (int8_t*)parsed_cmd, 5) == 0){ if (strncmp("shell", (int8_t*)parsed_cmd, 5) == 0){
terminal[running_terminal].pcb->shell_flag = 1; terminal[running_terminal].pcb->shell_flag = 1;
} }
...@@ -263,7 +264,7 @@ int32_t read(int32_t fd_n, void* buf, int32_t nbytes) ...@@ -263,7 +264,7 @@ int32_t read(int32_t fd_n, void* buf, int32_t nbytes)
/* /*
*The write system call *The write system call
* *
*DISCRIPTION: This function writes data to the terminal or to a device (RTC). *DESCRIPTION: This function writes data to the terminal or to a device (RTC).
* *
* case 1 - terminal: all data should be displayed to the screen immediately. * case 1 - terminal: all data should be displayed to the screen immediately.
* *
...@@ -297,7 +298,7 @@ int32_t write (int32_t fd, const void* buf, int32_t nbytes){ ...@@ -297,7 +298,7 @@ int32_t write (int32_t fd, const void* buf, int32_t nbytes){
/* /*
*The open system call *The open system call
* *
*DISCRIPTION: This function provides access to the file system, find the directory entry corresponding *DESCRIPTION: This function provides access to the file system, find the directory entry corresponding
* to the named file, allocate an unused file descriptor, and set up any data necessary * to the named file, allocate an unused file descriptor, and set up any data necessary
* to handle the given type of file (directory, RTC device, or regular file). * to handle the given type of file (directory, RTC device, or regular file).
* *
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment