Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
summeros
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Byron Lathi
summeros
Commits
0f81e7a0
Commit
0f81e7a0
authored
3 years ago
by
Byron Lathi
Browse files
Options
Downloads
Patches
Plain Diff
do elf loading a little better
parent
05f30526
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
fsdir/Programs/src/shell.c
+0
-4
0 additions, 4 deletions
fsdir/Programs/src/shell.c
kernel/Syscalls/execute.c
+8
-4
8 additions, 4 deletions
kernel/Syscalls/execute.c
kernel/Syscalls/execute.h
+1
-0
1 addition, 0 deletions
kernel/Syscalls/execute.h
with
9 additions
and
8 deletions
fsdir/Programs/src/shell.c
+
0
−
4
View file @
0f81e7a0
...
...
@@ -3,10 +3,6 @@
int
main
(
int
argc
,
char
**
argv
)
{
printf
(
"Hi
\n
"
);
printf
(
"Hi, %d
\n
"
,
1
);
int
i
;
for
(
i
=
0
;
i
<
argc
;
i
++
)
{
printf
(
"Arg%d: %s
\n
"
,
i
,
argv
[
i
]);
...
...
This diff is collapsed.
Click to expand it.
kernel/Syscalls/execute.c
+
8
−
4
View file @
0f81e7a0
...
...
@@ -177,8 +177,10 @@ int32_t _sys_exec(uint8_t* cmd)
}
map_large
(
EXEC_BASE_ADDR
,
_8MB
+
pid
*
_4MB
);
ext2_read_data
(
parsed_inode
,
0
,
(
uint16_t
*
)
EXEC_LOAD_ADDR
);
map_large
(
EXEC_BASE_ADDR
,
_8MB
+
pid
*
_4MB
);
//where program will be run
map_large
(
EXEC_TMP_ADDR
,
_8MB
+
(
pid
+
1
)
*
_4MB
);
// program loaded temporarily here, then copied over
ext2_read_data
(
parsed_inode
,
0
,
(
uint16_t
*
)
EXEC_TMP_ADDR
);
printf
(
"Loaded %s into %#x
\n
"
,
name
,
EXEC_TMP_ADDR
);
// what if you...
// read the program header to see how many bytes you needed to allocate and where
...
...
@@ -188,10 +190,12 @@ int32_t _sys_exec(uint8_t* cmd)
printf
(
"Program header %d type %x flags %x"
,
i
,
p_header
[
i
]
->
p_type
,
p_header
[
i
]
->
p_flags
);
printf
(
" offset %x vaddr %#x paddr %#x size %x
\n
"
,
p_header
[
i
]
->
p_offset
,
p_header
[
i
]
->
p_vaddr
,
p_header
[
i
]
->
p_paddr
,
p_header
[
i
]
->
p_filesz
);
// so there are the two program segments that we need to load.
memccpy
(
p_header
[
i
]
->
p_vaddr
,
EXEC_TMP_ADDR
+
p_header
[
i
]
->
p_offset
,
p_header
[
i
]
->
p_memsz
);
}
ext2_read_sectors
(
parsed_inode
,
p_header
[
1
]
->
p_offset
/
512
,
divhi
(
p_header
[
1
]
->
p_memsz
,
512
),
p_header
[
1
]
->
p_vaddr
);
unmap_large
(
EXEC_TMP_ADDR
);
//ext2_read_sectors(parsed_inode, p_header[1]->p_offset/512, divhi(p_header[1]->p_memsz, 512), p_header[1]->p_vaddr);
*
USER_ARGC
=
argc
;
...
...
This diff is collapsed.
Click to expand it.
kernel/Syscalls/execute.h
+
1
−
0
View file @
0f81e7a0
...
...
@@ -10,6 +10,7 @@
#define EXEC_BASE_ADDR 0x08000000
#define EXEC_LOAD_ADDR 0x08048000
#define EXEC_TMP_ADDR 0x0C000000
#define USER_ARGC (uint32_t*)0x83ffff8
#define USER_ARGV (uint8_t***)0x83ffffc
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment