Skip to content
Snippets Groups Projects
Commit fb557954 authored by xiangli's avatar xiangli
Browse files

22

parent eee2c059
No related branches found
No related tags found
No related merge requests found
......@@ -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 the video mem offset to virtual address and set to user level
* Function: map 2 pages after swith video memory
*/
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(){
......
......@@ -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
......@@ -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<64; i++)
for(i=0; i<256; 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)
......
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