static void generate_bootsect(uint32_t gpr[8], uint16_t segs[6], uint16_t ip)

{

    uint8_t bootsect[512], *p;

    int i;

    int hda;



    hda = drive_get_index(IF_IDE, 0, 0);

    if (hda == -1) {

	fprintf(stderr, "A disk image must be given for 'hda' when booting "

		"a Linux kernel\n(if you really don't want it, use /dev/zero)\n");

	exit(1);

    }



    memset(bootsect, 0, sizeof(bootsect));



    /* Copy the MSDOS partition table if possible */

    bdrv_read(drives_table[hda].bdrv, 0, bootsect, 1);



    /* Make sure we have a partition signature */

    bootsect[510] = 0x55;

    bootsect[511] = 0xaa;



    /* Actual code */

    p = bootsect;

    *p++ = 0xfa;		/* CLI */

    *p++ = 0xfc;		/* CLD */



    for (i = 0; i < 6; i++) {

	if (i == 1)		/* Skip CS */

	    continue;



	*p++ = 0xb8;		/* MOV AX,imm16 */

	*p++ = segs[i];

	*p++ = segs[i] >> 8;

	*p++ = 0x8e;		/* MOV <seg>,AX */

	*p++ = 0xc0 + (i << 3);

    }



    for (i = 0; i < 8; i++) {

	*p++ = 0x66;		/* 32-bit operand size */

	*p++ = 0xb8 + i;	/* MOV <reg>,imm32 */

	*p++ = gpr[i];

	*p++ = gpr[i] >> 8;

	*p++ = gpr[i] >> 16;

	*p++ = gpr[i] >> 24;

    }



    *p++ = 0xea;		/* JMP FAR */

    *p++ = ip;			/* IP */

    *p++ = ip >> 8;

    *p++ = segs[1];		/* CS */

    *p++ = segs[1] >> 8;



    bdrv_set_boot_sector(drives_table[hda].bdrv, bootsect, sizeof(bootsect));

}

static void generate_bootsect(uint32_t gpr[8], uint16_t segs[6], uint16_t ip)

{

    uint8_t bootsect[512], *p;

    int i;

    int hda;



    hda = drive_get_index(IF_IDE, 0, 0);

    if (hda == -1) {

	fprintf(stderr, "A disk image must be given for 'hda' when booting "

		"a Linux kernel\n(if you really don't want it, use /dev/zero)\n");

	exit(1);

    }



    memset(bootsect, 0, sizeof(bootsect));



    

    bdrv_read(drives_table[hda].bdrv, 0, bootsect, 1);



    

    bootsect[510] = 0x55;

    bootsect[511] = 0xaa;



    

    p = bootsect;

    *p++ = 0xfa;		

    *p++ = 0xfc;		



    for (i = 0; i < 6; i++) {

	if (i == 1)		

	    continue;



	*p++ = 0xb8;		

	*p++ = segs[i];

	*p++ = segs[i] >> 8;

	*p++ = 0x8e;		

	*p++ = 0xc0 + (i << 3);

    }



    for (i = 0; i < 8; i++) {

	*p++ = 0x66;		

	*p++ = 0xb8 + i;	

	*p++ = gpr[i];

	*p++ = gpr[i] >> 8;

	*p++ = gpr[i] >> 16;

	*p++ = gpr[i] >> 24;

    }



    *p++ = 0xea;		

    *p++ = ip;			

    *p++ = ip >> 8;

    *p++ = segs[1];		

    *p++ = segs[1] >> 8;



    bdrv_set_boot_sector(drives_table[hda].bdrv, bootsect, sizeof(bootsect));

}

static void FUNC_0(uint32_t VAR_0[8], uint16_t VAR_1[6], uint16_t VAR_2)

{

    uint8_t bootsect[512], *p;

    int VAR_3;

    int VAR_4;



    VAR_4 = drive_get_index(IF_IDE, 0, 0);

    if (VAR_4 == -1) {

	fprintf(stderr, "A disk image must be given for 'VAR_4' when booting "

		"a Linux kernel\n(if you really don't want it, use /dev/zero)\n");

	exit(1);

    }



    memset(bootsect, 0, sizeof(bootsect));



    

    bdrv_read(drives_table[VAR_4].bdrv, 0, bootsect, 1);



    

    bootsect[510] = 0x55;

    bootsect[511] = 0xaa;



    

    p = bootsect;

    *p++ = 0xfa;		

    *p++ = 0xfc;		



    for (VAR_3 = 0; VAR_3 < 6; VAR_3++) {

	if (VAR_3 == 1)		

	    continue;



	*p++ = 0xb8;		

	*p++ = VAR_1[VAR_3];

	*p++ = VAR_1[VAR_3] >> 8;

	*p++ = 0x8e;		

	*p++ = 0xc0 + (VAR_3 << 3);

    }



    for (VAR_3 = 0; VAR_3 < 8; VAR_3++) {

	*p++ = 0x66;		

	*p++ = 0xb8 + VAR_3;	

	*p++ = VAR_0[VAR_3];

	*p++ = VAR_0[VAR_3] >> 8;

	*p++ = VAR_0[VAR_3] >> 16;

	*p++ = VAR_0[VAR_3] >> 24;

    }



    *p++ = 0xea;		

    *p++ = VAR_2;			

    *p++ = VAR_2 >> 8;

    *p++ = VAR_1[1];		

    *p++ = VAR_1[1] >> 8;



    bdrv_set_boot_sector(drives_table[VAR_4].bdrv, bootsect, sizeof(bootsect));

}

static void FUNC_0(uint32_t VAR_0[8], uint16_t VAR_1[6], uint16_t VAR_2)
{ uint8_t bootsect[512], *p; int VAR_3; int VAR_4; VAR_4 = drive_get_index(IF_IDE, 0, 0); if (VAR_4 == -1) { fprintf(stderr, "A disk image must be given for 'VAR_4' when booting "
"a Linux kernel\n(if you really don't want it, use /dev/zero)\n"); exit(1); } memset(bootsect, 0, sizeof(bootsect)); bdrv_read(drives_table[VAR_4].bdrv, 0, bootsect, 1); bootsect[510] = 0x55; bootsect[511] = 0xaa; p = bootsect; *p++ = 0xfa; *p++ = 0xfc; for (VAR_3 = 0; VAR_3 < 6; VAR_3++) { if (VAR_3 == 1)
continue; *p++ = 0xb8; *p++ = VAR_1[VAR_3]; *p++ = VAR_1[VAR_3] >> 8; *p++ = 0x8e; *p++ = 0xc0 + (VAR_3 << 3); } for (VAR_3 = 0; VAR_3 < 8; VAR_3++) { *p++ = 0x66; *p++ = 0xb8 + VAR_3; *p++ = VAR_0[VAR_3]; *p++ = VAR_0[VAR_3] >> 8; *p++ = VAR_0[VAR_3] >> 16; *p++ = VAR_0[VAR_3] >> 24; } *p++ = 0xea; *p++ = VAR_2; *p++ = VAR_2 >> 8; *p++ = VAR_1[1]; *p++ = VAR_1[1] >> 8; bdrv_set_boot_sector(drives_table[VAR_4].bdrv, bootsect, sizeof(bootsect)); }