Skip to content
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

310551038 lab5–8 #127

Open
wants to merge 51 commits into
base: 310551038
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
2c23d35
Lab 5 C: Import kernel from lab 4
abt8601 Jun 1, 2023
bad36d5
Lab 5 C: Remove many consistency checks
abt8601 Jun 1, 2023
e9a89b2
Lab 5 C: Complete B1: Thread
abt8601 Jun 4, 2023
5c70a56
Lab 5 C: Complete B2: User Process and System Call
abt8601 Jun 19, 2023
e2e67f4
Lab 5 C: Complete B3: Video Player
abt8601 Jun 19, 2023
b8fc7ff
Lab 5 C: Fix `get_process_by_id`
abt8601 Jun 20, 2023
c1b6c25
Lab 5 C: Complete A1: POSIX Signal
abt8601 Jun 20, 2023
0dc4dd6
Lab 6 C: Import kernel from lab 5
abt8601 Jun 25, 2023
c833acc
Lab 6 C: Change default exception handler
abt8601 Jun 26, 2023
1760950
Lab 6 C: Complete B1
abt8601 Jun 26, 2023
1794c1a
Lab 6 C: Complete B2, B3, A2, A3
abt8601 Jun 27, 2023
bcfa76b
Lab 6 C: Fix memory attributes
abt8601 Jun 28, 2023
f3ee536
Lab 6 C: Fix `sys_mbox_call`
abt8601 Jun 28, 2023
c5925d1
Lab 7 C: Import kernel from lab 6
abt8601 Jun 28, 2023
b596fa4
Lab 7 C: Complete B1
abt8601 Jun 28, 2023
507855e
Lab 7 C: Complete B2
abt8601 Jun 28, 2023
8a64b30
Lab 7 C: Complete B3
abt8601 Jun 28, 2023
0a1b274
Lab 7 C: Complete B4
abt8601 Jun 28, 2023
27b4394
Lab 6 C: Fix `free`
abt8601 Jun 29, 2023
c56b5bd
Merge branch 'lab6' into lab7
abt8601 Jun 29, 2023
ee7f8b5
Lab 8 C: Import kernel from lab 7
abt8601 Jun 29, 2023
4cdedb4
Lab 8 C: Complete B1
abt8601 Jun 29, 2023
138c012
Lab 6 C: Complete A1
abt8601 Jun 29, 2023
5ae13f6
Merge branch 'lab6' into lab7
abt8601 Jun 29, 2023
8b0fd4e
Merge branch 'lab7' into lab8
abt8601 Jun 29, 2023
4f696ab
Merge branch 'lab8' into 310551038
abt8601 Jun 29, 2023
afe1588
Lab 6 C: Fix `exec` destroying memory regions
abt8601 Jun 30, 2023
811b98c
Merge branch 'lab6' into lab7
abt8601 Jun 30, 2023
f5012a6
Merge branch 'lab7' into lab8
abt8601 Jun 30, 2023
1b5db3c
Merge branch 'lab8' into 310551038
abt8601 Jun 30, 2023
c5d8f93
Lab 5 C: Fix run queue corruption
abt8601 Jun 30, 2023
7edf96f
Merge branch 'lab5' into lab6
abt8601 Jun 30, 2023
a2a4890
Merge branch 'lab6' into lab7
abt8601 Jun 30, 2023
a79e5fc
Merge branch 'lab7' into lab8
abt8601 Jun 30, 2023
306012e
Merge branch 'lab8' into 310551038
abt8601 Jun 30, 2023
05ac4e9
Lab 6 C: Fix `shared_page_decref`
abt8601 Jul 1, 2023
39f924e
Merge branch 'lab6' into lab7
abt8601 Jul 1, 2023
c9354cf
Merge branch 'lab7' into lab8
abt8601 Jul 1, 2023
c4faa22
Merge branch 'lab8' into 310551038
abt8601 Jul 1, 2023
1e6d2df
Lab 7 C: Complete A1
abt8601 Jul 10, 2023
cbef6e7
Lab 7 C: Change mknod implementation
abt8601 Jul 12, 2023
41019c4
Lab 7 C: Complete A2
abt8601 Jul 12, 2023
f507026
Lab 7 C: Use VFS API in `sys_exec`
abt8601 Jul 14, 2023
48aab76
Merge branch 'lab7' into lab8
abt8601 Jul 14, 2023
bb57655
Merge branch 'lab8' into 310551038
abt8601 Jul 14, 2023
9b06086
Lab 8 C: Fix issues with FAT
abt8601 Oct 17, 2023
9bcd6ec
Lab 8 C: Complete B2
abt8601 Oct 17, 2023
c9e686f
Lab 8 C: Add missing operations in sd_fat32
abt8601 Oct 18, 2023
a41a73a
Lab 8 C: Fix write and create in sd_fat32
abt8601 Oct 19, 2023
44e2dad
Lab 8 C: Complete A1
abt8601 Oct 19, 2023
db1be14
Merge branch 'lab8' into 310551038
abt8601 Oct 19, 2023
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
Prev Previous commit
Next Next commit
Lab 6 C: Complete A1
Other changes:

- Add a workaround for a run queue corruption but that causes terminated
  threads to be scheduled.
  • Loading branch information
abt8601 committed Jun 29, 2023
commit 138c0126fb840b34381d1b63d46123c94cb32b39
2 changes: 1 addition & 1 deletion lab6/c/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ OBJS = start main console devicetree initrd panic shell \
xcpt/syscall/uart-write xcpt/syscall/exec xcpt/syscall/fork \
xcpt/syscall/fork-impl xcpt/syscall/fork-child-ret \
xcpt/syscall/exit xcpt/syscall/mbox-call xcpt/syscall/kill \
xcpt/syscall/signal xcpt/syscall/signal-kill \
xcpt/syscall/signal xcpt/syscall/signal-kill xcpt/syscall/mmap \
xcpt/syscall/sigreturn xcpt/syscall/sigreturn-check \
libc/ctype libc/stdio libc/stdlib/qsort libc/string \
utils/core-id utils/fmt utils/heapq utils/rb
Expand Down
25 changes: 20 additions & 5 deletions lab6/c/include/oscos/mem/vm.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#include "oscos/mem/types.h"
#include "oscos/mem/vm/page-table.h"
#include "oscos/uapi/sys/mman.h"
#include "oscos/utils/rb.h"

/// \brief Converts a kernel space virtual address into its corresponding
/// physical address.
Expand All @@ -24,10 +26,15 @@ typedef struct {
mem_region_type_t type;
const void *backing_storage_start;
size_t backing_storage_len;
int prot;
} mem_region_t;

typedef struct {
mem_region_t text_region, stack_region, vc_region;
rb_node_t *root;
} mem_regions_t;

typedef struct {
mem_regions_t mem_regions;
page_table_entry_t *pgd;
} vm_addr_space_t;

Expand All @@ -37,11 +44,19 @@ typedef enum {
VM_MAP_PAGE_NOMEM
} vm_map_page_result_t;

page_table_entry_t *vm_new_pgd(void);
void vm_clone_pgd(page_table_entry_t *pgd);
void vm_drop_pgd(page_table_entry_t *pgd);
void vm_mem_regions_insert_region(mem_regions_t *regions,
const mem_region_t *region);
const mem_region_t *vm_mem_regions_find_region(const mem_regions_t *regions,
void *va);

vm_addr_space_t vm_new_addr_space(void);
vm_addr_space_t vm_clone_addr_space(vm_addr_space_t addr_space);
void vm_drop_addr_space(vm_addr_space_t pgd);
vm_map_page_result_t vm_map_page(vm_addr_space_t *addr_space, void *va);
vm_map_page_result_t vm_cow(vm_addr_space_t *addr_space, void *va);
vm_map_page_result_t vm_handle_permission_fault(vm_addr_space_t *addr_space,
void *va, int access_mode);
void vm_switch_to_addr_space(const vm_addr_space_t *addr_space);

void *vm_decide_mmap_addr(vm_addr_space_t addr_space, void *va, size_t len);

#endif
11 changes: 11 additions & 0 deletions lab6/c/include/oscos/uapi/sys/mman.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#ifndef OSCOS_UAPI_SYS_MMAN_H
#define OSCOS_UAPI_SYS_MMAN_H

#define PROT_NONE 0
#define PROT_READ 1
#define PROT_WRITE 2
#define PROT_EXEC 4

#define MAP_FAILED ((void *)-1)

#endif
3 changes: 2 additions & 1 deletion lab6/c/include/oscos/uapi/sys/syscall.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#define SYS_kill 7
#define SYS_signal 8
#define SYS_signal_kill 9
#define SYS_sigreturn 10
#define SYS_mmap 10
#define SYS_sigreturn 11

#endif
14 changes: 14 additions & 0 deletions lab6/c/include/oscos/utils/rb.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,28 @@ typedef struct rb_node_t {
alignas(16) unsigned char payload[];
} rb_node_t;

rb_node_t *rb_clone(const rb_node_t *root, size_t size,
bool (*cloner)(void *dst, const void *src),
void (*deleter)(void *payload));

const void *rb_search(const rb_node_t *root, const void *restrict key,
int (*compar)(const void *, const void *, void *),
void *arg);

const void *rb_predecessor(const rb_node_t *root, const void *restrict key,
int (*compar)(const void *, const void *, void *),
void *arg);

const void *rb_successor(const rb_node_t *root, const void *restrict key,
int (*compar)(const void *, const void *, void *),
void *arg);

bool rb_insert(rb_node_t **root, size_t size, const void *restrict item,
int (*compar)(const void *, const void *, void *), void *arg);

void rb_delete(rb_node_t **root, const void *restrict key,
int (*compar)(const void *, const void *, void *), void *arg);

void rb_drop(rb_node_t *root, void (*deleter)(void *payload));

#endif
Loading