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 如果全部通过,说明已经完成任务,可以进入下一个实验。

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值