MIT OS 2. Boot and Stack @Lab1

MIT OS课程主页:http://pdos.csail.mit.edu/6.828/2010/

这部分比较简单,按照主页上的指示去做就可以了。

Boot:

做完以后,想重写Boot Loader部分,遵循以下规则:

1.Enter unreal mode first
2.Load os-loader or os-kernel with 4G space mm though we are in real mode(unreal mode exactly)
3.Enter C code quick right after step1. Finish step2 after or in MBR?
4.Enable A20 and Goto Protected Mode
5.Jmp to os-loader or os-kernel 
Note:
1.Ensure MBR code as short as possible.Limit:446 bytes
2.os-loader code size as short as possible. Limit:31.5K bytes. Compress and Decompress? Muti-OS support?
3.os-kernel support other os-loader,eg: Grub.  ?  Self-Boot(Current Version)

 

 

 

 

Stack:

Code: //in mon_backtrace

 

        u32 * ptr;

        int i=0;

        cprintf("Stack backtrace:/n");

        ptr = (u32*)read_ebp();

        do

        {

                i++;

                if(i>20) break;  // void bad stack 

                cprintf("  ebp %x  eip %x  args %x %x %x %x %x/n",*ptr,*(ptr+1),*(ptr+2),*(ptr+3),*(ptr+4),*(ptr+5),*(ptr+6));

                ptr =(u32*) *ptr;

        } while(ptr != 0);

 

 

Output:

entering test_backtrace 0

 

Stack backtrace:

  ebp f0115f18  eip f010007b  args 0 0 0 0 f01008c0

  ebp f0115f38  eip f010007b  args 0 0 0 0 f01008c0

  ebp f0115f58  eip f0100068  args 0 1 f0115f78 0 f01008c0

  ebp f0115f78  eip f0100068  args 1 2 f0115f98 0 f01008c0

  ebp f0115f98  eip f0100068  args 2 3 f0115fb8 0 f01008c0

  ebp f0115fb8  eip f0100068  args 3 4 0 0 0

  ebp f0115fd8  eip f0100068  args 4 5 0 10074 10074

  ebp f0115ff8  eip f01000d4  args 5 1aac 660 0 0

  ebp 0  eip f010003d  args 0 0 ffff 10cf9a00 ffff

leaving test_backtrace 0

 

 

为了检查自己代码的效果,可以评估: make grade 如果全部通过,说明已经完成任务,可以进入下一个实验。

你可能感兴趣的:(c,OS,任务,output,2010)