-
Notifications
You must be signed in to change notification settings - Fork 71
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
Filesystem PR #428
Open
msdx321
wants to merge
16
commits into
gwsystems:loader
Choose a base branch
from
msdx321:filesystem
base: loader
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Filesystem PR #428
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
aaa6206
.gitmodules: Update
msdx321 ffb9d4a
libc: Fix compile
msdx321 2886df2
ps: Set to my fork
msdx321 f212c5e
posix: Make it work for now
msdx321 99ff0ff
blockdev: Add blockdev interface
msdx321 d766845
blockdev: Add ramdisk implementation
msdx321 36b64ab
ramdisk: Add a small test
msdx321 0cd3014
filesystem: Add filesystem interface
msdx321 35b3d71
filesystem: Add ext4 implementation
msdx321 0e23944
ext4: Add a small test
msdx321 17658d9
lwext4: Add as a lib
msdx321 8639c6e
.gitignore: Update
msdx321 45a40d8
blockdev: Add some comments
msdx321 d74209e
filesystem: Add some comments
msdx321 c06ee97
ramdisk_tests: Update
msdx321 43c1034
ext4_tests: Update
msdx321 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
[submodule "src/components/lib/ps/ps"] | ||
path = src/components/lib/ps/ps | ||
url = https://github.com/gwsystems/ps.git | ||
url = https://github.com/msdx321/ps.git | ||
[submodule "src/components/lib/ck/ck"] | ||
path = src/components/lib/ck/ck | ||
url = https://github.com/gwsystems/ck.git | ||
[submodule "src/components/lib/lwext4/lwext4"] | ||
path = src/components/lib/lwext4/lwext4 | ||
url = https://github.com/msdx321/lwext4.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
[system] | ||
description = "Simplest system with both capability manager and scheduler, from unit_schedcomp.sh" | ||
|
||
[[components]] | ||
name = "booter" | ||
img = "no_interface.llbooter" | ||
implements = [{interface = "init"}, {interface = "addr"}] | ||
deps = [{srv = "kernel", interface = "init", variant = "kernel"}] | ||
constructor = "kernel" | ||
|
||
[[components]] | ||
name = "capmgr" | ||
img = "capmgr.simple" | ||
deps = [{srv = "booter", interface = "init"}, {srv = "booter", interface = "addr"}] | ||
implements = [{interface = "capmgr"}, {interface = "init"}, {interface = "memmgr"}, {interface = "capmgr_create"}] | ||
constructor = "booter" | ||
|
||
[[components]] | ||
name = "sched" | ||
img = "sched.root_fprr" | ||
deps = [{srv = "capmgr", interface = "init"}, {srv = "capmgr", interface = "capmgr"}, {srv = "capmgr", interface = "memmgr"}] | ||
implements = [{interface = "sched"}, {interface = "init"}] | ||
constructor = "booter" | ||
|
||
[[components]] | ||
name = "blockdev" | ||
img = "blockdev.ramdisk" | ||
deps = [{srv = "sched", interface = "init"}, {srv = "capmgr", interface = "capmgr_create"}, {srv = "capmgr", interface = "memmgr"}] | ||
implements = [{interface = "blockdev"}] | ||
constructor = "booter" | ||
|
||
[[components]] | ||
name = "filesystem" | ||
img = "filesystem.ext4" | ||
deps = [{srv = "sched", interface = "init"}, {srv = "capmgr", interface = "capmgr_create"}, {srv = "blockdev", interface = "blockdev"}, {srv = "capmgr", interface = "memmgr"}] | ||
implements = [{interface = "filesystem"}] | ||
constructor = "booter" | ||
|
||
[[components]] | ||
name = "ext4_tests" | ||
img = "tests.ext4_tests" | ||
deps = [{srv = "sched", interface = "init"}, {srv = "capmgr", interface = "capmgr_create"}, {srv = "filesystem", interface = "filesystem"}, {srv = "capmgr", interface = "memmgr"}] | ||
constructor = "booter" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
[system] | ||
description = "Simplest system with both capability manager and scheduler, from unit_schedcomp.sh" | ||
|
||
[[components]] | ||
name = "booter" | ||
img = "no_interface.llbooter" | ||
implements = [{interface = "init"}, {interface = "addr"}] | ||
deps = [{srv = "kernel", interface = "init", variant = "kernel"}] | ||
constructor = "kernel" | ||
|
||
[[components]] | ||
name = "capmgr" | ||
img = "capmgr.simple" | ||
deps = [{srv = "booter", interface = "init"}, {srv = "booter", interface = "addr"}] | ||
implements = [{interface = "capmgr"}, {interface = "init"}, {interface = "memmgr"}, {interface = "capmgr_create"}] | ||
constructor = "booter" | ||
|
||
[[components]] | ||
name = "sched" | ||
img = "sched.root_fprr" | ||
deps = [{srv = "capmgr", interface = "init"}, {srv = "capmgr", interface = "capmgr"}, {srv = "capmgr", interface = "memmgr"}] | ||
implements = [{interface = "sched"}, {interface = "init"}] | ||
constructor = "booter" | ||
|
||
[[components]] | ||
name = "blockdev" | ||
img = "blockdev.ramdisk" | ||
deps = [{srv = "sched", interface = "init"}, {srv = "capmgr", interface = "capmgr_create"}, {srv = "capmgr", interface = "memmgr"}] | ||
implements = [{interface = "blockdev"}] | ||
constructor = "booter" | ||
|
||
[[components]] | ||
name = "ramdisk_tests" | ||
img = "tests.ramdisk_tests" | ||
deps = [{srv = "sched", interface = "init"}, {srv = "capmgr", interface = "capmgr_create"}, {srv = "blockdev", interface = "blockdev"}, {srv = "capmgr", interface = "memmgr"}] | ||
constructor = "booter" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Required variables used to drive the compilation process. It is OK | ||
# for many of these to be empty. | ||
# | ||
# The set of interfaces that this component exports for use by other | ||
# components. This is a list of the interface names. | ||
INTERFACE_EXPORTS = blockdev | ||
# The interfaces this component is dependent on for compilation (this | ||
# is a list of directory names in interface/) | ||
INTERFACE_DEPENDENCIES = memmgr | ||
# The library dependencies this component is reliant on for | ||
# compilation/linking (this is a list of directory names in lib/) | ||
LIBRARY_DEPENDENCIES = component | ||
# Note: Both the interface and library dependencies should be | ||
# *minimal*. That is to say that removing a dependency should cause | ||
# the build to fail. The build system does not validate this | ||
# minimality; that's on you! | ||
|
||
include Makefile.subdir |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Required variables used to drive the compilation process. It is OK | ||
# for many of these to be empty. | ||
# | ||
# The set of interfaces that this component exports for use by other | ||
# components. This is a list of the interface names. | ||
INTERFACE_EXPORTS = blockdev | ||
# The interfaces this component is dependent on for compilation (this | ||
# is a list of directory names in interface/) | ||
INTERFACE_DEPENDENCIES = memmgr | ||
# The library dependencies this component is reliant on for | ||
# compilation/linking (this is a list of directory names in lib/) | ||
LIBRARY_DEPENDENCIES = component | ||
# Note: Both the interface and library dependencies should be | ||
# *minimal*. That is to say that removing a dependency should cause | ||
# the build to fail. The build system does not validate this | ||
# minimality; that's on you! | ||
|
||
include Makefile.subsubdir |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
## Ramdisk | ||
|
||
### Description | ||
|
||
This is a simple implementation of ramdisk on composite using blockdev interface. | ||
|
||
### Usage and Assumptions | ||
|
||
- Default blocksize is 4K | ||
- Default total disk size is 16MiB | ||
- Supports block read and block write only |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#include <cos_component.h> | ||
#include <llprint.h> | ||
#include <memmgr.h> | ||
|
||
#define BLOCKDEV_RAMDISK_BSIZE 4096 // 4K block size | ||
#define BLOCKDEV_RAMDISK_SIZE 16 * 1024 * 1024 // 16 MiB ramdisk size | ||
|
||
typedef struct block { | ||
char c[BLOCKDEV_RAMDISK_BSIZE]; | ||
} blk; | ||
|
||
blk *ram_backend; | ||
|
||
unsigned int | ||
blockdev_bread(void *buf, unsigned long offset, unsigned long length) | ||
{ | ||
memcpy(buf, &ram_backend[offset], length * BLOCKDEV_RAMDISK_BSIZE); | ||
return 0; | ||
} | ||
|
||
unsigned int | ||
blockdev_bwrite(const void *buf, unsigned long offset, unsigned long length) | ||
{ | ||
memcpy(&ram_backend[offset], buf, length * BLOCKDEV_RAMDISK_BSIZE); | ||
return 0; | ||
} | ||
|
||
void | ||
cos_init(void) | ||
{ | ||
ram_backend = (blk *)memmgr_heap_page_allocn(BLOCKDEV_RAMDISK_SIZE / 4096); | ||
return; | ||
} | ||
|
||
void | ||
cos_parallel_init(coreid_t cid, int init_core, int ncores) | ||
{ | ||
return; | ||
} | ||
|
||
void | ||
parallel_main(coreid_t cid) | ||
{ | ||
return; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Required variables used to drive the compilation process. It is OK | ||
# for many of these to be empty. | ||
# | ||
# The set of interfaces that this component exports for use by other | ||
# components. This is a list of the interface names. | ||
INTERFACE_EXPORTS = filesystem | ||
# The interfaces this component is dependent on for compilation (this | ||
# is a list of directory names in interface/) | ||
INTERFACE_DEPENDENCIES = blockdev | ||
# The library dependencies this component is reliant on for | ||
# compilation/linking (this is a list of directory names in lib/) | ||
LIBRARY_DEPENDENCIES = component | ||
# Note: Both the interface and library dependencies should be | ||
# *minimal*. That is to say that removing a dependency should cause | ||
# the build to fail. The build system does not validate this | ||
# minimality; that's on you! | ||
|
||
include Makefile.subdir |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Required variables used to drive the compilation process. It is OK | ||
# for many of these to be empty. | ||
# | ||
# The set of interfaces that this component exports for use by other | ||
# components. This is a list of the interface names. | ||
INTERFACE_EXPORTS = filesystem | ||
# The interfaces this component is dependent on for compilation (this | ||
# is a list of directory names in interface/) | ||
INTERFACE_DEPENDENCIES = blockdev memmgr | ||
# The library dependencies this component is reliant on for | ||
# compilation/linking (this is a list of directory names in lib/) | ||
LIBRARY_DEPENDENCIES = component lwext4 posix libc ps | ||
# Note: Both the interface and library dependencies should be | ||
# *minimal*. That is to say that removing a dependency should cause | ||
# the build to fail. The build system does not validate this | ||
# minimality; that's on you! | ||
|
||
include Makefile.subsubdir |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
## filesystem | ||
|
||
### Description | ||
|
||
An implementation of ext4 filesystem by using lwext4. | ||
|
||
### Usage and Assumptions | ||
|
||
See `filesystem.h` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
#include <cos_component.h> | ||
#include <llprint.h> | ||
#include <ext4.h> | ||
#include <ext4_mkfs.h> | ||
#include <ps_ns.h> | ||
|
||
extern struct ext4_blockdev *ext4_blockdev_get(void); | ||
static struct ext4_blockdev *bd; | ||
|
||
static struct ext4_fs fs; | ||
static int fs_type = F_SET_EXT4; | ||
static struct ext4_mkfs_info info = { | ||
.block_size = 4096, | ||
.journal = true, | ||
}; | ||
static struct ext4_bcache *bc; | ||
|
||
struct ps_ns *ns[64]; | ||
|
||
PS_NSSLAB_CREATE(fd, sizeof(struct ext4_file), 2, 9, 6); | ||
|
||
word_t | ||
filesystem_fopen(const char *path, const char *flags) | ||
{ | ||
ps_desc_t fd; | ||
ext4_file *file; | ||
compid_t token; | ||
|
||
token = (compid_t)cos_inv_token(); | ||
|
||
fd = -1; | ||
file = ps_nsptr_alloc_fd(ns[token], &fd); | ||
int ret = ext4_fopen(file, path, flags); | ||
//printc("ret %d\n", ret); | ||
|
||
//printc("mp %p\n", file->mp); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removing debug print or using printd() looks better. |
||
|
||
return (word_t)fd; | ||
} | ||
|
||
int | ||
filesystem_fclose(word_t fd) | ||
{ | ||
compid_t token; | ||
token = (compid_t)cos_inv_token(); | ||
|
||
return ext4_fclose(ps_nsptr_lkup_fd(ns[token], fd)); | ||
} | ||
|
||
int | ||
filesystem_ftruncate(word_t fd, unsigned long size) | ||
{ | ||
compid_t token; | ||
token = (compid_t)cos_inv_token(); | ||
|
||
return ext4_ftruncate(ps_nsptr_lkup_fd(ns[token], fd), size); | ||
} | ||
|
||
size_t | ||
filesystem_fread(word_t fd, void *buf, size_t size) | ||
{ | ||
size_t rcnt; | ||
compid_t token; | ||
token = (compid_t)cos_inv_token(); | ||
|
||
int ret = ext4_fread(ps_nsptr_lkup_fd(ns[token], fd), buf, size, &rcnt); | ||
//printc("fread ret %d rcnt %d\n", ret, rcnt); | ||
|
||
return rcnt; | ||
} | ||
|
||
size_t | ||
filesystem_fwrite(word_t fd, void *buf, size_t size) | ||
{ | ||
size_t wcnt; | ||
compid_t token; | ||
|
||
token = (compid_t)cos_inv_token(); | ||
|
||
//printc("fwrite writing %s\n", buf); | ||
|
||
int ret = ext4_fwrite(ps_nsptr_lkup_fd(ns[token], fd), buf, size, &wcnt); | ||
//printc("fwrite ret %d wcnt %d\n", ret, wcnt); | ||
|
||
return wcnt; | ||
} | ||
|
||
int | ||
filesystem_fseek(word_t fd, long offset, unsigned long origin) | ||
{ | ||
compid_t token; | ||
token = (compid_t)cos_inv_token(); | ||
|
||
return ext4_fseek(ps_nsptr_lkup_fd(ns[token], fd), offset, origin); | ||
} | ||
|
||
unsigned long | ||
filesystem_ftell(word_t fd) | ||
{ | ||
compid_t token; | ||
token = (compid_t)cos_inv_token(); | ||
|
||
return ext4_ftell(ps_nsptr_lkup_fd(ns[token], fd)); | ||
} | ||
|
||
unsigned long | ||
filesystem_fsize(word_t fd) | ||
{ | ||
compid_t token; | ||
token = (compid_t)cos_inv_token(); | ||
|
||
return ext4_fsize(ps_nsptr_lkup_fd(ns[token], fd)); | ||
} | ||
|
||
void | ||
cos_init(void) | ||
{ | ||
for (int i = 0; i < 64; i++) { ns[i] = ps_nsptr_create_slab_fd(); } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Define 64 to be a meaningful symbol should be better. |
||
|
||
bd = ext4_blockdev_get(); | ||
// ext4_dmask_set(DEBUG_ALL); | ||
|
||
ext4_mkfs(&fs, bd, &info, fs_type); | ||
ext4_device_register(bd, "ext4_fs"); // Register our ramdisk as ext4_fs | ||
ext4_mount("ext4_fs", "/", false); // Mount fs to root | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could first update the ps port, so we don't need to change the url here