summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2009-05-29 15:10:27 -0700
committerH. Peter Anvin <hpa@zytor.com>2009-05-29 15:10:27 -0700
commit23a0327eecd30d3a90f18a62e9ec3be8c208baeb (patch)
treee1133e0cc6c994a5bd15c053be58953490f0b2ea
parenta8b17a6024d5f41e3251e9eeb9f9ef494cba3eaa (diff)
downloadsyslinux-23a0327eecd30d3a90f18a62e9ec3be8c208baeb.tar.gz
Run Nindent on com32/lib/syslinux/memscan.c
Automatically reformat com32/lib/syslinux/memscan.c using Nindent. Do this for all files except HDT, gPXE and externally maintained libraries (zlib, tinyjpeg, libpng). Signed-off-by: H. Peter Anvin <hpa@zytor.com>
-rw-r--r--com32/lib/syslinux/memscan.c188
1 files changed, 94 insertions, 94 deletions
diff --git a/com32/lib/syslinux/memscan.c b/com32/lib/syslinux/memscan.c
index 07439207..95580257 100644
--- a/com32/lib/syslinux/memscan.c
+++ b/com32/lib/syslinux/memscan.c
@@ -42,112 +42,112 @@
#include <syslinux/memscan.h>
struct e820_entry {
- uint64_t start;
- uint64_t len;
- uint32_t type;
+ uint64_t start;
+ uint64_t len;
+ uint32_t type;
};
int syslinux_scan_memory(scan_memory_callback_t callback, void *data)
{
- static com32sys_t ireg;
- com32sys_t oreg;
- struct e820_entry *e820buf = __com32.cs_bounce;
- uint64_t start, len, maxlen;
- int memfound = 0;
- int rv;
- addr_t dosmem;
- const addr_t bios_data = 0x510; /* Amount to reserve for BIOS data */
-
- /* Use INT 12h to get DOS memory */
- __intcall(0x12, &__com32_zero_regs, &oreg);
- dosmem = oreg.eax.w[0] << 10;
- if (dosmem < 32*1024 || dosmem > 640*1024) {
- /* INT 12h reports nonsense... now what? */
- uint16_t ebda_seg = *(uint16_t *)0x40e;
- if (ebda_seg >= 0x8000 && ebda_seg < 0xa000)
- dosmem = ebda_seg << 4;
- else
- dosmem = 640*1024; /* Hope for the best... */
- }
- rv = callback(data, bios_data, dosmem-bios_data, true);
- if (rv)
- return rv;
-
- /* First try INT 15h AX=E820h */
- ireg.eax.l = 0xe820;
- ireg.edx.l = 0x534d4150;
- ireg.ebx.l = 0;
- ireg.ecx.l = sizeof(*e820buf);
- ireg.es = SEG(e820buf);
- ireg.edi.w[0] = OFFS(e820buf);
- memset(e820buf, 0, sizeof *e820buf);
-
- do {
- __intcall(0x15, &ireg, &oreg);
-
- if ((oreg.eflags.l & EFLAGS_CF) ||
- (oreg.eax.l != 0x534d4150) ||
- (oreg.ecx.l < 20))
- break;
-
- start = e820buf->start;
- len = e820buf->len;
-
- if (start < 0x100000000ULL) {
- /* Don't rely on E820 being valid for low memory. Doing so
- could mean stuff like overwriting the PXE stack even when
- using "keeppxe", etc. */
- if (start < 0x100000ULL) {
- if (len > 0x100000ULL-start)
- len -= 0x100000ULL-start;
+ static com32sys_t ireg;
+ com32sys_t oreg;
+ struct e820_entry *e820buf = __com32.cs_bounce;
+ uint64_t start, len, maxlen;
+ int memfound = 0;
+ int rv;
+ addr_t dosmem;
+ const addr_t bios_data = 0x510; /* Amount to reserve for BIOS data */
+
+ /* Use INT 12h to get DOS memory */
+ __intcall(0x12, &__com32_zero_regs, &oreg);
+ dosmem = oreg.eax.w[0] << 10;
+ if (dosmem < 32 * 1024 || dosmem > 640 * 1024) {
+ /* INT 12h reports nonsense... now what? */
+ uint16_t ebda_seg = *(uint16_t *) 0x40e;
+ if (ebda_seg >= 0x8000 && ebda_seg < 0xa000)
+ dosmem = ebda_seg << 4;
else
- len = 0;
- start = 0x100000ULL;
- }
-
- maxlen = 0x100000000ULL-start;
- if (len > maxlen)
- len = maxlen;
-
- if (len) {
- rv = callback(data, (addr_t)start, (addr_t)len, e820buf->type == 1);
- if (rv)
- return rv;
- memfound = 1;
- }
+ dosmem = 640 * 1024; /* Hope for the best... */
}
+ rv = callback(data, bios_data, dosmem - bios_data, true);
+ if (rv)
+ return rv;
- ireg.ebx.l = oreg.ebx.l;
- } while (oreg.ebx.l);
+ /* First try INT 15h AX=E820h */
+ ireg.eax.l = 0xe820;
+ ireg.edx.l = 0x534d4150;
+ ireg.ebx.l = 0;
+ ireg.ecx.l = sizeof(*e820buf);
+ ireg.es = SEG(e820buf);
+ ireg.edi.w[0] = OFFS(e820buf);
+ memset(e820buf, 0, sizeof *e820buf);
+
+ do {
+ __intcall(0x15, &ireg, &oreg);
+
+ if ((oreg.eflags.l & EFLAGS_CF) ||
+ (oreg.eax.l != 0x534d4150) || (oreg.ecx.l < 20))
+ break;
+
+ start = e820buf->start;
+ len = e820buf->len;
+
+ if (start < 0x100000000ULL) {
+ /* Don't rely on E820 being valid for low memory. Doing so
+ could mean stuff like overwriting the PXE stack even when
+ using "keeppxe", etc. */
+ if (start < 0x100000ULL) {
+ if (len > 0x100000ULL - start)
+ len -= 0x100000ULL - start;
+ else
+ len = 0;
+ start = 0x100000ULL;
+ }
+
+ maxlen = 0x100000000ULL - start;
+ if (len > maxlen)
+ len = maxlen;
+
+ if (len) {
+ rv = callback(data, (addr_t) start, (addr_t) len,
+ e820buf->type == 1);
+ if (rv)
+ return rv;
+ memfound = 1;
+ }
+ }
+
+ ireg.ebx.l = oreg.ebx.l;
+ } while (oreg.ebx.l);
+
+ if (memfound)
+ return 0;
+
+ /* Next try INT 15h AX=E801h */
+ ireg.eax.w[0] = 0xe801;
+ __intcall(0x15, &ireg, &oreg);
- if (memfound)
- return 0;
+ if (!(oreg.eflags.l & EFLAGS_CF) && oreg.ecx.w[0]) {
+ rv = callback(data, (addr_t) 1 << 20, oreg.ecx.w[0] << 10, true);
+ if (rv)
+ return rv;
- /* Next try INT 15h AX=E801h */
- ireg.eax.w[0] = 0xe801;
- __intcall(0x15, &ireg, &oreg);
+ if (oreg.edx.w[0]) {
+ rv = callback(data, (addr_t) 16 << 20, oreg.edx.w[0] << 16, true);
+ if (rv)
+ return rv;
+ }
- if (!(oreg.eflags.l & EFLAGS_CF) && oreg.ecx.w[0]) {
- rv = callback(data, (addr_t)1 << 20, oreg.ecx.w[0] << 10, true);
- if (rv)
- return rv;
+ return 0;
+ }
- if (oreg.edx.w[0]) {
- rv = callback(data, (addr_t)16 << 20, oreg.edx.w[0] << 16, true);
- if (rv)
- return rv;
+ /* Finally try INT 15h AH=88h */
+ ireg.eax.w[0] = 0x8800;
+ if (!(oreg.eflags.l & EFLAGS_CF) && oreg.eax.w[0]) {
+ rv = callback(data, (addr_t) 1 << 20, oreg.ecx.w[0] << 10, true);
+ if (rv)
+ return rv;
}
return 0;
- }
-
- /* Finally try INT 15h AH=88h */
- ireg.eax.w[0] = 0x8800;
- if (!(oreg.eflags.l & EFLAGS_CF) && oreg.eax.w[0]) {
- rv = callback(data, (addr_t)1 << 20, oreg.ecx.w[0] << 10, true);
- if (rv)
- return rv;
- }
-
- return 0;
}