aboutsummaryrefslogtreecommitdiffstats
path: root/memdump
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2009-05-29 15:10:36 -0700
committerH. Peter Anvin <hpa@zytor.com>2009-05-29 15:10:36 -0700
commit3761a8a5592f20dfad5f64879d80960c2541e0c8 (patch)
tree8cb38dab8033ff99a75c203416a2d29e62658219 /memdump
parent93d2d1f5e8454645be7977656fce4f07513cde38 (diff)
downloadsyslinux.git-3761a8a5592f20dfad5f64879d80960c2541e0c8.tar.gz
syslinux.git-3761a8a5592f20dfad5f64879d80960c2541e0c8.tar.xz
syslinux.git-3761a8a5592f20dfad5f64879d80960c2541e0c8.zip
Run Nindent on memdump/main.c
Automatically reformat memdump/main.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>
Diffstat (limited to 'memdump')
-rw-r--r--memdump/main.c156
1 files changed, 78 insertions, 78 deletions
diff --git a/memdump/main.c b/memdump/main.c
index f408926e..02f2a4fc 100644
--- a/memdump/main.c
+++ b/memdump/main.c
@@ -19,13 +19,13 @@
const char *program = "memdump";
-void __attribute__((noreturn)) die(const char *msg)
+void __attribute__ ((noreturn)) die(const char *msg)
{
- puts(program);
- puts(": ");
- puts(msg);
- putchar('\n');
- exit(1);
+ puts(program);
+ puts(": ");
+ puts(msg);
+ putchar('\n');
+ exit(1);
}
#ifdef DEBUG
@@ -34,11 +34,12 @@ void __attribute__((noreturn)) die(const char *msg)
# define dprintf(...) ((void)0)
#endif
-static inline __attribute__((const)) uint16_t ds(void)
+static inline __attribute__ ((const))
+uint16_t ds(void)
{
- uint16_t v;
- asm("movw %%ds,%0" : "=rm" (v));
- return v;
+ uint16_t v;
+asm("movw %%ds,%0":"=rm"(v));
+ return v;
}
#define GDT_ENTRY(flags,base,limit) \
@@ -51,91 +52,90 @@ static inline __attribute__((const)) uint16_t ds(void)
static void get_bytes(void *buf, size_t len, struct file_info *finfo,
size_t pos)
{
- size_t end;
- static uint64_t gdt[6];
- size_t bufl;
-
- pos += (size_t)finfo->pvt; /* Add base */
- end = pos+len;
-
- if (end <= 0x100000) {
- /* Can stay in real mode */
- asm volatile("movw %3,%%fs ; "
- "fs; rep; movsl ; "
- "movw %2,%%cx ; "
- "rep; movsb"
- : : "D" (buf), "c" (len >> 2), "r" ((uint16_t)(len & 3)),
- "rm" ((uint16_t)(pos >> 4)), "S" (pos & 15)
- : "memory");
- } else {
- bufl = (ds() << 4)+(size_t)buf;
- gdt[2] = GDT_ENTRY(0x0093, pos, 0xffff);
- gdt[3] = GDT_ENTRY(0x0093, bufl, 0xffff);
- asm volatile("pushal ; int $0x15 ; popal"
- : : "a" (0x8700), "c" ((len+1) >> 1), "S" (&gdt)
- : "memory");
- }
+ size_t end;
+ static uint64_t gdt[6];
+ size_t bufl;
+
+ pos += (size_t) finfo->pvt; /* Add base */
+ end = pos + len;
+
+ if (end <= 0x100000) {
+ /* Can stay in real mode */
+ asm volatile ("movw %3,%%fs ; "
+ "fs; rep; movsl ; "
+ "movw %2,%%cx ; "
+ "rep; movsb"::"D" (buf), "c"(len >> 2),
+ "r"((uint16_t) (len & 3)), "rm"((uint16_t) (pos >> 4)),
+ "S"(pos & 15)
+ :"memory");
+ } else {
+ bufl = (ds() << 4) + (size_t) buf;
+ gdt[2] = GDT_ENTRY(0x0093, pos, 0xffff);
+ gdt[3] = GDT_ENTRY(0x0093, bufl, 0xffff);
+ asm volatile ("pushal ; int $0x15 ; popal"::"a" (0x8700),
+ "c"((len + 1) >> 1), "S"(&gdt)
+ :"memory");
+ }
}
int main(int argc, char *argv[])
{
- uint16_t bios_ports[4];
- const char *prefix;
- char filename[1024];
- int i;
- static struct serial_if sif =
- {
- .read = serial_read,
- .write = serial_write,
+ uint16_t bios_ports[4];
+ const char *prefix;
+ char filename[1024];
+ int i;
+ static struct serial_if sif = {
+ .read = serial_read,
+ .write = serial_write,
};
- struct file_info finfo;
- const char serial_banner[] = "Now begin Ymodem download...\r\n";
+ struct file_info finfo;
+ const char serial_banner[] = "Now begin Ymodem download...\r\n";
- if (argc < 4)
- die("usage: memdump port prefix start,len...");
+ if (argc < 4)
+ die("usage: memdump port prefix start,len...");
- finfo.pvt = (void *)0x400;
- get_bytes(bios_ports, 8, &finfo, 0); /* Get BIOS serial ports */
+ finfo.pvt = (void *)0x400;
+ get_bytes(bios_ports, 8, &finfo, 0); /* Get BIOS serial ports */
- for (i = 0; i < 4; i++)
- printf("ttyS%i (COM%i) is at %#x\n", i, i+1, bios_ports[i]);
+ for (i = 0; i < 4; i++)
+ printf("ttyS%i (COM%i) is at %#x\n", i, i + 1, bios_ports[i]);
- sif.port = strtoul(argv[1], NULL, 0);
- if (sif.port <= 3) {
- sif.port = bios_ports[sif.port];
- }
+ sif.port = strtoul(argv[1], NULL, 0);
+ if (sif.port <= 3) {
+ sif.port = bios_ports[sif.port];
+ }
- if (serial_init(&sif))
- die("failed to initialize serial port");
+ if (serial_init(&sif))
+ die("failed to initialize serial port");
- prefix = argv[2];
+ prefix = argv[2];
- puts("Printing prefix...\n");
- sif.write(&sif, serial_banner, sizeof serial_banner-1);
+ puts("Printing prefix...\n");
+ sif.write(&sif, serial_banner, sizeof serial_banner - 1);
- for (i = 3; i < argc; i++) {
- uint32_t start, len;
- char *ep;
+ for (i = 3; i < argc; i++) {
+ uint32_t start, len;
+ char *ep;
- start = strtoul(argv[i], &ep, 0);
- if (*ep != ',')
- die("invalid range specification");
- len = strtoul(ep+1, NULL, 0);
+ start = strtoul(argv[i], &ep, 0);
+ if (*ep != ',')
+ die("invalid range specification");
+ len = strtoul(ep + 1, NULL, 0);
- sprintf(filename, "%s%#x-%#x.bin", prefix, start, len);
- finfo.name = filename;
- finfo.size = len;
- finfo.pvt = (void *)start;
+ sprintf(filename, "%s%#x-%#x.bin", prefix, start, len);
+ finfo.name = filename;
+ finfo.size = len;
+ finfo.pvt = (void *)start;
- puts("Sending ");
- puts(filename);
- puts("...\n");
+ puts("Sending ");
+ puts(filename);
+ puts("...\n");
- send_ymodem(&sif, &finfo, get_bytes);
- }
+ send_ymodem(&sif, &finfo, get_bytes);
+ }
- puts("Sending closing signature...\n");
- end_ymodem(&sif);
+ puts("Sending closing signature...\n");
+ end_ymodem(&sif);
- return 0;
+ return 0;
}