MIT 6.828的os引导中的指令是什么意思?

这是引导程序的主要功能

/* bootmain - the entry of bootloader */
void
bootmain(void) {
    // read the 1st page off disk
    readseg((uintptr_t)ELFHDR,SECTSIZE * 8,0);

    // is this a valid ELF?
    if (ELFHDR->e_magic != ELF_MAGIC) {
        goto bad;
    }

    struct proghdr *ph,*eph;

    // load each program segment (ignores ph flags)
    ph = (struct proghdr *)((uintptr_t)ELFHDR + ELFHDR->e_phoff);
    eph = ph + ELFHDR->e_phnum;
    for (; ph < eph; ph ++) {
        readseg(ph->p_va & 0xFFFFFF,ph->p_memsz,ph->p_offset);
    }

    // call the entry point from the ELF header
    // note: does not return
    ((void (*)(void))(ELFHDR->e_entry & 0xFFFFFF))();

bad:
    outw(0x8A00,0x8A00);
    outw(0x8A00,0x8E00);

    /* do nothing */
    while (1);
}

我对最后一个指令的含义感到好奇,它们是'outw(0x8A00,0x8A00); outw(0x8A00,0x8E00);' 如您所知,内核函数将永远不会返回。 函数outw定义如下,它只在使用指定端口进行I / O。

static inline void
outw(uint16_t port,uint16_t data) {
    asm volatile ("outw %0,%1" :: "a" (data),"d" (port));
}

此外,我想知道为什么从ELF读取的每个虚拟地址都应为Logic And,例如0xFFFFFF。 ph-> p_va和0xFFFFFF。如果没有逻辑与运算怎么办?

tian9085 回答:MIT 6.828的os引导中的指令是什么意思?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3169045.html

大家都在问