From f518048021b2532b266c2dee934ccff6aac2304e Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Fri, 29 May 2009 15:10:27 -0700 Subject: [PATCH] Run Nindent on com32/lib/syslinux/shuffle_rm.c Automatically reformat com32/lib/syslinux/shuffle_rm.c using Nindent. Do this for all files except HDT, gPXE and externally maintained libraries (zlib, tinyjpeg, libpng). Signed-off-by: H. Peter Anvin --- com32/lib/syslinux/shuffle_rm.c | 172 ++++++++++++++++++++-------------------- 1 file changed, 86 insertions(+), 86 deletions(-) diff --git a/com32/lib/syslinux/shuffle_rm.c b/com32/lib/syslinux/shuffle_rm.c index ccb4f95..a7d16d6 100644 --- a/com32/lib/syslinux/shuffle_rm.c +++ b/com32/lib/syslinux/shuffle_rm.c @@ -76,96 +76,96 @@ enum seg_index { R_ES, R_CS, R_SS, R_DS, R_FS, R_GS }; int syslinux_shuffle_boot_rm(struct syslinux_movelist *fraglist, struct syslinux_memmap *memmap, - uint16_t bootflags, - struct syslinux_rm_regs *regs) + uint16_t bootflags, struct syslinux_rm_regs *regs) { - const struct syslinux_rm_regs_alt { - uint16_t seg[6]; - uint32_t gpr[8]; - uint32_t csip; - bool sti; - } *rp; - int i, rv; - uint8_t handoff_code[8+5*5+8*6+1+5], *p; - uint16_t off; - struct syslinux_memmap *tmap; - addr_t regstub, stublen; - /* Assign GPRs for each sreg, don't use AX and SP */ - static const uint8_t gpr_for_seg[6] = { R_CX, R_DX, R_BX, R_BP, R_SI, R_DI }; - - tmap = syslinux_target_memmap(fraglist, memmap); - if (!tmap) - return -1; - - /* - * Search for a good place to put the real-mode register stub. - * We prefer it as low as possible above 0x800. KVM barfs horribly - * if we're not aligned to a paragraph boundary, so set the alignment - * appropriately. - */ - regstub = 0x800; - stublen = sizeof handoff_code; - rv = syslinux_memmap_find(tmap, SMT_FREE, ®stub, &stublen, 16); - - if (rv || (regstub > 0x100000 - sizeof handoff_code)) { + const struct syslinux_rm_regs_alt { + uint16_t seg[6]; + uint32_t gpr[8]; + uint32_t csip; + bool sti; + } *rp; + int i, rv; + uint8_t handoff_code[8 + 5 * 5 + 8 * 6 + 1 + 5], *p; + uint16_t off; + struct syslinux_memmap *tmap; + addr_t regstub, stublen; + /* Assign GPRs for each sreg, don't use AX and SP */ + static const uint8_t gpr_for_seg[6] = + { R_CX, R_DX, R_BX, R_BP, R_SI, R_DI }; + + tmap = syslinux_target_memmap(fraglist, memmap); + if (!tmap) + return -1; + /* - * Uh-oh. This isn't real-mode accessible memory. - * It might be possible to do something insane here like - * putting the stub in the IRQ vectors, or in the 0x5xx segment. - * This code tries the 0x510-0x7ff range and hopes for the best. + * Search for a good place to put the real-mode register stub. + * We prefer it as low as possible above 0x800. KVM barfs horribly + * if we're not aligned to a paragraph boundary, so set the alignment + * appropriately. */ - regstub = 0x510; /* Try the 0x5xx segment... */ + regstub = 0x800; stublen = sizeof handoff_code; rv = syslinux_memmap_find(tmap, SMT_FREE, ®stub, &stublen, 16); - if (!rv && (regstub > 0x100000 - sizeof handoff_code)) - rv = -1; /* No acceptable memory found */ - } - - syslinux_free_memmap(tmap); - if (rv) - return -1; - - /* Build register-setting stub */ - p = handoff_code; - rp = (const struct syslinux_rm_regs_alt *)regs; - - /* Set up GPRs with segment registers - don't use AX */ - for (i = 0; i < 6; i++) { - if (i != R_CS) - MOV_TO_R16(p, gpr_for_seg[i], rp->seg[i]); - } - - /* Actual transition to real mode */ - ST32(p, 0xeac0220f); /* MOV CR0,EAX; JMP FAR */ - off = (p-handoff_code)+4; - ST16(p, off); /* Offset */ - ST16(p,regstub >> 4); /* Segment */ - - /* Load SS and ESP immediately */ - MOV_TO_SEG(p, R_SS, R_BX); - MOV_TO_R32(p, R_SP, rp->gpr[R_SP]); - - /* Load the other segments */ - MOV_TO_SEG(p, R_ES, R_CX); - MOV_TO_SEG(p, R_DS, R_BP); - MOV_TO_SEG(p, R_FS, R_SI); - MOV_TO_SEG(p, R_GS, R_DI); - - for (i = 0; i < 8; i++) { - if (i != R_SP) - MOV_TO_R32(p, i, rp->gpr[i]); - } - - ST8(p, rp->sti ? 0xfb : 0xfa); /* STI/CLI */ - - ST8(p, 0xea); /* JMP FAR */ - ST32(p, rp->csip); - - /* Add register-setting stub to shuffle list */ - if (syslinux_add_movelist(&fraglist, regstub, (addr_t)handoff_code, - sizeof handoff_code)) - return -1; - - return syslinux_do_shuffle(fraglist, memmap, regstub, 0, bootflags); + if (rv || (regstub > 0x100000 - sizeof handoff_code)) { + /* + * Uh-oh. This isn't real-mode accessible memory. + * It might be possible to do something insane here like + * putting the stub in the IRQ vectors, or in the 0x5xx segment. + * This code tries the 0x510-0x7ff range and hopes for the best. + */ + regstub = 0x510; /* Try the 0x5xx segment... */ + stublen = sizeof handoff_code; + rv = syslinux_memmap_find(tmap, SMT_FREE, ®stub, &stublen, 16); + + if (!rv && (regstub > 0x100000 - sizeof handoff_code)) + rv = -1; /* No acceptable memory found */ + } + + syslinux_free_memmap(tmap); + if (rv) + return -1; + + /* Build register-setting stub */ + p = handoff_code; + rp = (const struct syslinux_rm_regs_alt *)regs; + + /* Set up GPRs with segment registers - don't use AX */ + for (i = 0; i < 6; i++) { + if (i != R_CS) + MOV_TO_R16(p, gpr_for_seg[i], rp->seg[i]); + } + + /* Actual transition to real mode */ + ST32(p, 0xeac0220f); /* MOV CR0,EAX; JMP FAR */ + off = (p - handoff_code) + 4; + ST16(p, off); /* Offset */ + ST16(p, regstub >> 4); /* Segment */ + + /* Load SS and ESP immediately */ + MOV_TO_SEG(p, R_SS, R_BX); + MOV_TO_R32(p, R_SP, rp->gpr[R_SP]); + + /* Load the other segments */ + MOV_TO_SEG(p, R_ES, R_CX); + MOV_TO_SEG(p, R_DS, R_BP); + MOV_TO_SEG(p, R_FS, R_SI); + MOV_TO_SEG(p, R_GS, R_DI); + + for (i = 0; i < 8; i++) { + if (i != R_SP) + MOV_TO_R32(p, i, rp->gpr[i]); + } + + ST8(p, rp->sti ? 0xfb : 0xfa); /* STI/CLI */ + + ST8(p, 0xea); /* JMP FAR */ + ST32(p, rp->csip); + + /* Add register-setting stub to shuffle list */ + if (syslinux_add_movelist(&fraglist, regstub, (addr_t) handoff_code, + sizeof handoff_code)) + return -1; + + return syslinux_do_shuffle(fraglist, memmap, regstub, 0, bootflags); } -- 2.7.4