Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
Redstone
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor 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
zefanxu2
Redstone
Commits
fb557954
Commit
fb557954
authored
8 years ago
by
xiangli
Browse files
Options
Downloads
Patches
Plain Diff
22
parent
eee2c059
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
student-distrib/paging.c
+7
-8
7 additions, 8 deletions
student-distrib/paging.c
student-distrib/paging.h
+1
-1
1 addition, 1 deletion
student-distrib/paging.h
student-distrib/systemcall.c
+16
-14
16 additions, 14 deletions
student-distrib/systemcall.c
with
24 additions
and
23 deletions
student-distrib/paging.c
+
7
−
8
View file @
fb557954
...
...
@@ -17,14 +17,14 @@ uint32_t kernel_page_table[ONEKB] __attribute__((aligned(FOURKB)));
/*
* void switch_pd(uint32_t addr)
* Inputs: the address to map
* Return Value: none
* Function: map the physical address and set to user level
* Function: page physical address
*/
void
switch_pd
(
uint32_t
addr
){
pd_array
[
USER_PAGE
]
=
addr
|
FOURMB_USER
;
//set to user level
int32_t
cr3
;
//TLB flusH
//flush the tlb
asm
volatile
(
"movl %%cr3, %0
\n
\
movl %0, %%cr3"
\
...
...
@@ -41,13 +41,14 @@ void switch_pd(uint32_t addr){
* void switch_video_pd(uint32_t addr, int terminal_id)
* Inputs: the address to map, and the offset to the displaying terminal
* Return Value: none
* Function: map 2 pages after th
e
video mem
offset to virtual address and set to user level
* Function: map 2 pages after
swi
th video mem
ory
*/
void
switch_video_pd
(
uint32_t
addr
,
int
terminal_id
){
kernel_page_table
[
video
+
terminal_id
*
2
]
=
addr
|
USER_not_present
;
//set to user level
int32_t
cr3
;
//TLB flusH
//flush the tlb
asm
volatile
(
"movl %%cr3, %0
\n
\
movl %0, %%cr3"
\
...
...
@@ -62,9 +63,7 @@ void switch_video_pd(uint32_t addr, int terminal_id){
/*
* void paging_init()
* Inputs: none
* Return Value: none
* Function: initialize the paging
* Function: init the paging
*/
void
paging_init
(){
...
...
This diff is collapsed.
Click to expand it.
student-distrib/paging.h
+
1
−
1
View file @
fb557954
...
...
@@ -8,4 +8,4 @@ void paging_init();
void
switch_pd
(
uint32_t
addr
);
void
switch_video_pd
(
uint32_t
addr
,
int
terminal_id
);
#endif
/* _RTC_H */
#endif
This diff is collapsed.
Click to expand it.
student-distrib/systemcall.c
+
16
−
14
View file @
fb557954
...
...
@@ -24,8 +24,9 @@
#define SOUND_PORT_CMD 0x43
#define SOUND_IO_PORT 0x61
int
freq
[
64
]
=
{
130
,
195
,
261
,
311
,
391
,
311
,
261
,
195
,
130
,
195
,
261
,
311
,
97
,
146
,
195
,
233
,
103
,
155
,
207
,
261
,
311
,
261
,
207
,
155
,
103
,
155
,
261
,
311
,
207
,
349
,
207
,
391
,
195
,
174
,
233
,
293
,
174
,
233
,
293
,
349
,
155
,
233
,
311
,
349
,
97
,
146
,
195
,
233
,
174
,
155
,
207
,
311
,
207
,
155
,
164
,
207
,
155
,
261
,
311
,
466
,
155
,
415
,
207
,
391
};
int
dur
[
64
]
=
{
400
,
400
,
400
,
400
,
400
,
400
,
400
,
400
,
400
,
400
,
400
,
400
,
400
,
400
,
400
,
400
,
400
,
400
,
400
,
400
,
400
,
400
,
400
,
400
,
400
,
400
,
400
,
400
,
400
,
400
,
400
,
400
,
400
,
400
,
400
,
400
,
400
,
400
,
400
,
400
,
400
,
400
,
400
,
400
,
400
,
400
,
400
,
400
,
400
,
400
,
400
,
400
,
400
,
400
,
400
,
400
,
400
,
200
,
200
,
400
,
400
,
400
,
400
,
400
};
int
freq
[
256
]
=
{
130
,
130
,
130
,
130
,
195
,
195
,
195
,
195
,
261
,
261
,
261
,
261
,
311
,
311
,
311
,
311
,
391
,
391
,
391
,
391
,
311
,
311
,
311
,
311
,
261
,
261
,
261
,
261
,
195
,
195
,
195
,
195
,
130
,
130
,
130
,
130
,
195
,
195
,
195
,
195
,
261
,
261
,
261
,
261
,
311
,
311
,
311
,
311
,
97
,
97
,
97
,
97
,
146
,
146
,
146
,
146
,
195
,
195
,
195
,
195
,
233
,
233
,
233
,
233
,
103
,
103
,
103
,
103
,
155
,
155
,
155
,
155
,
207
,
207
,
207
,
207
,
261
,
261
,
261
,
261
,
311
,
311
,
311
,
311
,
261
,
261
,
261
,
261
,
207
,
207
,
207
,
207
,
155
,
155
,
155
,
155
,
103
,
103
,
103
,
103
,
155
,
155
,
155
,
155
,
261
,
261
,
261
,
261
,
311
,
311
,
311
,
311
,
207
,
207
,
207
,
207
,
349
,
349
,
349
,
349
,
207
,
207
,
207
,
207
,
391
,
391
,
391
,
391
,
349
,
116
,
349
,
116
,
174
,
174
,
174
,
174
,
233
,
233
,
233
,
233
,
293
,
293
,
293
,
293
,
174
,
174
,
174
,
174
,
233
,
233
,
233
,
233
,
293
,
293
,
293
,
293
,
349
,
349
,
349
,
349
,
155
,
155
,
155
,
155
,
233
,
233
,
233
,
233
,
311
,
311
,
311
,
311
,
349
,
349
,
349
,
349
,
97
,
97
,
97
,
97
,
146
,
146
,
146
,
146
,
195
,
195
,
195
,
195
,
233
,
233
,
233
,
233
,
293
,
103
,
293
,
103
,
155
,
155
,
155
,
155
,
207
,
207
,
207
,
207
,
311
,
311
,
311
,
311
,
207
,
207
,
207
,
207
,
155
,
155
,
155
,
155
,
261
,
103
,
261
,
103
,
207
,
207
,
207
,
207
,
155
,
155
,
155
,
155
,
261
,
261
,
261
,
261
,
311
,
311
,
311
,
311
,
466
,
466
,
466
,
466
,
155
,
155
,
155
,
155
,
415
,
415
,
415
,
415
,
207
,
207
,
207
,
207
,
391
,
391
,
391
,
391
};
int
dur
[
256
]
=
{
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
50
,
50
,
50
,
50
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
50
,
50
,
50
,
50
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
50
,
50
,
50
,
50
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
50
,
50
,
50
,
50
,
50
,
50
,
50
,
50
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
,
100
};
typedef
int32_t
func
();
...
...
@@ -60,20 +61,20 @@ void sing_song (int freq_number, uint32_t duration){
outb
((
uint8_t
)((
divv
>>
8
)
&
0xff
),
SOUND_PORT_DATA
);
uint8_t
tmp
=
inb
(
0x61
);
uint8_t
tmp
=
inb
(
SOUND_IO_PORT
);
if
(
tmp
!=
(
tmp
|
3
)){
outb
(
tmp
|
3
,
0x61
);
outb
(
tmp
|
3
,
SOUND_IO_PORT
);
}
int32_t
i
=
duration
;
//duration is millisecond
int32_t
j
=
(
int
)
65535
*
2
;
//somehow too fast
int32_t
j
=
(
int
)
65535
*
1
.
5
;
//somehow too fast
//65553 is 16bit cpu_speed
//no time for setting magical number!
for
(
i
=
duration
;
i
>
0
;
i
--
){
while
(
j
>
0
){
j
--
;
}
j
=
(
int
)
65535
*
2
;
j
=
(
int
)
65535
*
1
.
5
;
}
...
...
@@ -85,7 +86,7 @@ void song()
{
int
i
;
for
(
i
=
0
;
i
<
6
4
;
i
++
)
for
(
i
=
0
;
i
<
25
6
;
i
++
)
{
sing_song
(
freq
[
i
],
dur
[
i
]);
}
...
...
@@ -96,7 +97,7 @@ void song()
* int32_t halt (uint8_t status)
* Inputs: status
* Return Value: never return or 0 on success
* Function:
halt the
current process
* Function: current process
halt
*/
int32_t
halt
(
uint8_t
status
)
{
...
...
@@ -133,7 +134,7 @@ int32_t halt (uint8_t status) {
/*
* void
halt_fd
()
* void
clear_file_descriptors
()
* Inputs: none
* Return Value: none
* Function: halt the current fd
...
...
@@ -149,7 +150,7 @@ void clear_file_descriptors() {
* int32_t execute(const uint8_t * command)
* Inputs: the command to execute
* Return Value: the status on success and -1 on failure or error condition
* Function: execute
the given command
* Function: execute
*/
int32_t
execute
(
const
uint8_t
*
command
)
{
...
...
@@ -159,13 +160,14 @@ int32_t execute(const uint8_t * command) {
int
file_type
;
int
eip
=
0
;
dentry_t
temp
;
uint32_t
esp
,
ebp
;
uint8_t
USER_EIP
[
4
];
uint8_t
ELF_check_bytes
[
4
];
int32_t
command_len
=
0
;
int32_t
argument_lem
=
0
;
uint8_t
executable_file
[
128
];
uint8_t
command_args
[
128
];
uint32_t
esp
,
ebp
;
uint8_t
USER_EIP
[
4
];
uint8_t
ELF_check_bytes
[
4
];
if
(
command
==
NULL
)
...
...
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