コード例 #1
0
ファイル: kaboom.c プロジェクト: Celelibi/syslinux
__export __noreturn _kaboom(void)
{
    extern void kaboom(void);
    call16(kaboom, &zero_regs, NULL);
    /* Do this if kaboom somehow returns... */
    for (;;)
	asm volatile("hlt");
}
コード例 #2
0
ファイル: localboot.c プロジェクト: Celelibi/syslinux
/*
 * Boot a specified local disk.  AX specifies the BIOS disk number; or
 * -1 in case we should execute INT 18h ("next device.")
 */
__export void local_boot(int16_t ax)
{
	com32sys_t ireg, oreg;
	int i;

        memset(&ireg, 0, sizeof(ireg));
	syslinux_force_text_mode();

	writestr(LOCALBOOT_MSG);
	crlf();
	cleanup_hardware();

	if (ax == -1) {
		/* Hope this does the right thing */
		__intcall(0x18, &zero_regs, NULL);

		/* If we returned, oh boy... */
		kaboom();
	}

	/*
	 * Load boot sector from the specified BIOS device and jump to
	 * it.
	 */
	memset(&ireg, 0, sizeof ireg);
	ireg.edx.b[0] = ax & 0xff;
	ireg.eax.w[0] = 0;	/* Reset drive */
	__intcall(0x13, &ireg, NULL);

	memset(&ireg, 0, sizeof(ireg));
	ireg.eax.w[0] = 0x0201;	/* Read one sector */
	ireg.ecx.w[0] = 0x0001;	/* C/H/S = 0/0/1 (first sector) */
	ireg.ebx.w[0] = OFFS(trackbuf);
	ireg.es = SEG(trackbuf);

	for (i = 0; i < retry_count; i++) {
		__intcall(0x13, &ireg, &oreg);

		if (!(oreg.eflags.l & EFLAGS_CF))
			break;
	}

	if (i == retry_count)
		kaboom();

	cli();			/* Abandon hope, ye who enter here */
	memcpy((void *)0x07C00, trackbuf, 512);

	ireg.esi.w[0] = OFFS(trackbuf);
	ireg.edi.w[0] = 0x07C00;
	ireg.edx.w[0] = ax;
	call16(local_boot16, &ireg, NULL);
}
コード例 #3
0
ファイル: pxe.c プロジェクト: emmericp/syslinux
/*
 * the ASM pxenv function wrapper, return 1 if error, or 0
 *
 */
__export int pxe_call(int opcode, void *data)
{
    static DECLARE_INIT_SEMAPHORE(pxe_sem, 1);
    extern void pxenv(void);
    com32sys_t regs;

    sem_down(&pxe_sem, 0);

#if 0
    dprintf("pxe_call op %04x data %p\n", opcode, data);
#endif

    memset(&regs, 0, sizeof regs);
    regs.ebx.w[0] = opcode;
    regs.es       = SEG(data);
    regs.edi.w[0] = OFFS(data);
    call16(pxenv, &regs, &regs);

    sem_up(&pxe_sem);

    return regs.eflags.l & EFLAGS_CF;  /* CF SET if fail */
}
コード例 #4
0
ファイル: loadhigh.c プロジェクト: 1stMaster/syslinux
void pm_load_high(com32sys_t *regs)
{
    struct fs_info *fs;
    uint32_t bytes;
    uint32_t zero_mask;
    bool have_more;
    uint32_t bytes_read;
    char *buf, *limit;
    struct file *file;
    uint32_t sector_mask;
    size_t pad;
    uint32_t retflags = 0;

    bytes     = regs->eax.l;
    zero_mask = regs->edx.w[0];
    buf       = (char *)regs->edi.l;
    limit     = (char *)(regs->ebp.l & ~zero_mask);
    file      = handle_to_file(regs->esi.w[0]);
    fs        = file->fs;

    sector_mask = SECTOR_SIZE(fs) - 1;

    while (bytes) {
	uint32_t sectors;
	uint32_t chunk;

	if (buf + SECTOR_SIZE(fs) > limit) {
	    /* Can't fit even one more sector in... */
	    retflags = EFLAGS_OF;
	    break;
	}

	chunk = bytes;

	if (regs->ebx.w[0]) {
	    call16((void (*)(void))(size_t)regs->ebx.w[0], &zero_regs, NULL);
	    chunk = min(chunk, MAX_CHUNK);
	}

	if (chunk > (((char *)limit - buf) & ~sector_mask))
	    chunk = ((char *)limit - buf) & ~sector_mask;

	sectors = (chunk + sector_mask) >> SECTOR_SHIFT(fs);
	bytes_read = fs->fs_ops->getfssec(file, buf, sectors, &have_more);

	if (bytes_read > chunk)
	    bytes_read = chunk;

	buf += bytes_read;
	bytes -= bytes_read;

	if (!have_more) {
	    /*
	     * If we reach EOF, the filesystem driver will have already closed
	     * the underlying file... this really should be cleaner.
	     */
	    _close_file(file);
	    regs->esi.w[0] = 0;
	    retflags = EFLAGS_CF;
	    break;
	}
    }

    pad = (size_t)buf & zero_mask;
    if (pad)
	memset(buf, 0, pad);

    regs->ebx.l = (size_t)buf;
    regs->edi.l = (size_t)buf + pad;
    set_flags(regs, retflags);
}