Commit 5fafdf24ef2c090c164d4dc89684b3f379dbdd87

Authored by ths
1 parent bd494f4c

find -type f | xargs sed -i 's/[\t ]$//g' # on most files


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3173 c046a42c-6fe2-441c-8c8c-71466251a162

Too many changes to show.

To preserve performance only 26 of 327 files are displayed.

Changelog
@@ -86,7 +86,7 @@ version 0.8.0: @@ -86,7 +86,7 @@ version 0.8.0:
86 (Johannes Schindelin) 86 (Johannes Schindelin)
87 87
88 version 0.7.2: 88 version 0.7.2:
89 - 89 +
90 - x86_64 fixes (Win2000 and Linux 2.6 boot in 32 bit) 90 - x86_64 fixes (Win2000 and Linux 2.6 boot in 32 bit)
91 - merge self modifying code handling in dirty ram page mecanism. 91 - merge self modifying code handling in dirty ram page mecanism.
92 - MIPS fixes (Ralf Baechle) 92 - MIPS fixes (Ralf Baechle)
@@ -135,7 +135,7 @@ version 0.6.1: @@ -135,7 +135,7 @@ version 0.6.1:
135 - Mac OS X port (Pierre d'Herbemont) 135 - Mac OS X port (Pierre d'Herbemont)
136 - Virtual console support 136 - Virtual console support
137 - Better monitor line edition 137 - Better monitor line edition
138 - - New block device layer 138 + - New block device layer
139 - New 'qcow' growable disk image support with AES encryption and 139 - New 'qcow' growable disk image support with AES encryption and
140 transparent decompression 140 transparent decompression
141 - VMware 3 and 4 read-only disk image support (untested) 141 - VMware 3 and 4 read-only disk image support (untested)
@@ -201,7 +201,7 @@ version 0.5.5: @@ -201,7 +201,7 @@ version 0.5.5:
201 - FDC fixes for Win98 201 - FDC fixes for Win98
202 202
203 version 0.5.4: 203 version 0.5.4:
204 - 204 +
205 - qemu-fast fixes 205 - qemu-fast fixes
206 - BIOS area protection fix (aka EMM386.EXE fix) (Mike Nordell) 206 - BIOS area protection fix (aka EMM386.EXE fix) (Mike Nordell)
207 - keyboard/mouse fix (Mike Nordell) 207 - keyboard/mouse fix (Mike Nordell)
@@ -228,7 +228,7 @@ version 0.5.3: @@ -228,7 +228,7 @@ version 0.5.3:
228 - added accurate CR0.MP/ME/TS emulation 228 - added accurate CR0.MP/ME/TS emulation
229 - fixed DMA memory write access (Win95 boot floppy fix) 229 - fixed DMA memory write access (Win95 boot floppy fix)
230 - graphical x86 linux loader 230 - graphical x86 linux loader
231 - - command line monitor 231 + - command line monitor
232 - generic removable device support 232 - generic removable device support
233 - support of CD-ROM change 233 - support of CD-ROM change
234 - multiple network interface support 234 - multiple network interface support
@@ -266,7 +266,7 @@ version 0.5.2: @@ -266,7 +266,7 @@ version 0.5.2:
266 - eflags optimisation fix for string operations 266 - eflags optimisation fix for string operations
267 267
268 version 0.5.1: 268 version 0.5.1:
269 - 269 +
270 - float access fixes when using soft mmu 270 - float access fixes when using soft mmu
271 - PC emulation support on PowerPC 271 - PC emulation support on PowerPC
272 - A20 support 272 - A20 support
@@ -281,7 +281,7 @@ version 0.5.1: @@ -281,7 +281,7 @@ version 0.5.1:
281 - Major SPARC target fixes (dynamically linked programs begin to work) 281 - Major SPARC target fixes (dynamically linked programs begin to work)
282 282
283 version 0.5.0: 283 version 0.5.0:
284 - 284 +
285 - full hardware level VGA emulation 285 - full hardware level VGA emulation
286 - graphical display with SDL 286 - graphical display with SDL
287 - added PS/2 mouse and keyboard emulation 287 - added PS/2 mouse and keyboard emulation
@@ -319,7 +319,7 @@ version 0.4.2: @@ -319,7 +319,7 @@ version 0.4.2:
319 - SMP kernels can at least be booted 319 - SMP kernels can at least be booted
320 320
321 version 0.4.1: 321 version 0.4.1:
322 - 322 +
323 - more accurate timer support in vl. 323 - more accurate timer support in vl.
324 - more reliable NE2000 probe in vl. 324 - more reliable NE2000 probe in vl.
325 - added 2.5.66 kernel in vl-test. 325 - added 2.5.66 kernel in vl-test.
@@ -405,7 +405,7 @@ version 0.1.3: @@ -405,7 +405,7 @@ version 0.1.3:
405 - added bound, cmpxchg8b, cpuid instructions 405 - added bound, cmpxchg8b, cpuid instructions
406 - added 16 bit addressing support/override for string operations 406 - added 16 bit addressing support/override for string operations
407 - poll() fix 407 - poll() fix
408 - 408 +
409 version 0.1.2: 409 version 0.1.2:
410 410
411 - compile fixes 411 - compile fixes
Makefile
@@ -40,7 +40,7 @@ dyngen$(EXESUF): dyngen.c @@ -40,7 +40,7 @@ dyngen$(EXESUF): dyngen.c
40 40
41 clean: 41 clean:
42 # avoid old build problems by removing potentially incorrect old files 42 # avoid old build problems by removing potentially incorrect old files
43 - rm -f config.mak config.h op-i386.h opc-i386.h gen-op-i386.h op-arm.h opc-arm.h gen-op-arm.h 43 + rm -f config.mak config.h op-i386.h opc-i386.h gen-op-i386.h op-arm.h opc-arm.h gen-op-arm.h
44 rm -f *.o *.a $(TOOLS) dyngen$(EXESUF) TAGS cscope.* *.pod *~ */*~ 44 rm -f *.o *.a $(TOOLS) dyngen$(EXESUF) TAGS cscope.* *.pod *~ */*~
45 $(MAKE) -C tests clean 45 $(MAKE) -C tests clean
46 for d in $(TARGET_DIRS); do \ 46 for d in $(TARGET_DIRS); do \
@@ -89,7 +89,7 @@ endif @@ -89,7 +89,7 @@ endif
89 test speed test2: all 89 test speed test2: all
90 $(MAKE) -C tests $@ 90 $(MAKE) -C tests $@
91 91
92 -TAGS: 92 +TAGS:
93 etags *.[ch] tests/*.[ch] 93 etags *.[ch] tests/*.[ch]
94 94
95 cscope: 95 cscope:
Makefile.target
@@ -269,7 +269,7 @@ OBJS+= libqemu.a @@ -269,7 +269,7 @@ OBJS+= libqemu.a
269 269
270 # cpu emulator library 270 # cpu emulator library
271 LIBOBJS=exec.o kqemu.o translate-op.o translate-all.o cpu-exec.o\ 271 LIBOBJS=exec.o kqemu.o translate-op.o translate-all.o cpu-exec.o\
272 - translate.o op.o 272 + translate.o op.o
273 ifdef CONFIG_SOFTFLOAT 273 ifdef CONFIG_SOFTFLOAT
274 LIBOBJS+=fpu/softfloat.o 274 LIBOBJS+=fpu/softfloat.o
275 else 275 else
@@ -317,7 +317,7 @@ LIBOBJS+= op_helper.o helper.o alpha_palcode.o @@ -317,7 +317,7 @@ LIBOBJS+= op_helper.o helper.o alpha_palcode.o
317 endif 317 endif
318 318
319 # NOTE: the disassembler code is only needed for debugging 319 # NOTE: the disassembler code is only needed for debugging
320 -LIBOBJS+=disas.o 320 +LIBOBJS+=disas.o
321 ifeq ($(findstring i386, $(TARGET_ARCH) $(ARCH)),i386) 321 ifeq ($(findstring i386, $(TARGET_ARCH) $(ARCH)),i386)
322 USE_I386_DIS=y 322 USE_I386_DIS=y
323 endif 323 endif
@@ -483,7 +483,7 @@ VL_OBJS+= an5206.o mcf5206.o ptimer.o mcf_uart.o mcf_intc.o mcf5208.o mcf_fec.o @@ -483,7 +483,7 @@ VL_OBJS+= an5206.o mcf5206.o ptimer.o mcf_uart.o mcf_intc.o mcf5208.o mcf_fec.o
483 VL_OBJS+= m68k-semi.o 483 VL_OBJS+= m68k-semi.o
484 endif 484 endif
485 ifdef CONFIG_GDBSTUB 485 ifdef CONFIG_GDBSTUB
486 -VL_OBJS+=gdbstub.o 486 +VL_OBJS+=gdbstub.o
487 endif 487 endif
488 ifdef CONFIG_SDL 488 ifdef CONFIG_SDL
489 VL_OBJS+=sdl.o x_keymap.o 489 VL_OBJS+=sdl.o x_keymap.o
@@ -511,7 +511,7 @@ ifdef CONFIG_STATIC @@ -511,7 +511,7 @@ ifdef CONFIG_STATIC
511 VL_LDFLAGS+=-static 511 VL_LDFLAGS+=-static
512 endif 512 endif
513 ifndef CONFIG_SOFTMMU 513 ifndef CONFIG_SOFTMMU
514 -VL_LDFLAGS+=-Wl,-T,$(SRC_PATH)/i386-vl.ld 514 +VL_LDFLAGS+=-Wl,-T,$(SRC_PATH)/i386-vl.ld
515 endif 515 endif
516 ifndef CONFIG_DARWIN 516 ifndef CONFIG_DARWIN
517 ifndef CONFIG_WIN32 517 ifndef CONFIG_WIN32
@@ -561,7 +561,7 @@ depend: $(SRCS) @@ -561,7 +561,7 @@ depend: $(SRCS)
561 vldepend: $(VL_OBJS:.o=.c) 561 vldepend: $(VL_OBJS:.o=.c)
562 $(CC) -MM $(CFLAGS) $(CPPFLAGS) $(BASE_CFLAGS) $^ 1>.depend 562 $(CC) -MM $(CFLAGS) $(CPPFLAGS) $(BASE_CFLAGS) $^ 1>.depend
563 563
564 -# libqemu 564 +# libqemu
565 565
566 libqemu.a: $(LIBOBJS) 566 libqemu.a: $(LIBOBJS)
567 rm -f $@ 567 rm -f $@
@@ -665,7 +665,7 @@ $(OBJS) $(LIBOBJS) $(VL_OBJS): config.h ../config-host.h @@ -665,7 +665,7 @@ $(OBJS) $(LIBOBJS) $(VL_OBJS): config.h ../config-host.h
665 clean: 665 clean:
666 rm -f *.o *.a *~ $(PROGS) gen-op.h opc.h op.h nwfpe/*.o slirp/*.o fpu/*.o 666 rm -f *.o *.a *~ $(PROGS) gen-op.h opc.h op.h nwfpe/*.o slirp/*.o fpu/*.o
667 667
668 -install: all 668 +install: all
669 ifneq ($(PROGS),) 669 ifneq ($(PROGS),)
670 $(INSTALL) -m 755 -s $(PROGS) "$(DESTDIR)$(bindir)" 670 $(INSTALL) -m 755 -s $(PROGS) "$(DESTDIR)$(bindir)"
671 endif 671 endif
@@ -16,7 +16,7 @@ short term: @@ -16,7 +16,7 @@ short term:
16 - do not resize vga if invalid size. 16 - do not resize vga if invalid size.
17 - avoid looping if only exceptions 17 - avoid looping if only exceptions
18 - TLB code protection support for PPC 18 - TLB code protection support for PPC
19 -- see openMosix Doc 19 +- see openMosix Doc
20 - disable SMC handling for ARM/SPARC/PPC (not finished) 20 - disable SMC handling for ARM/SPARC/PPC (not finished)
21 - see undefined flags for BTx insn 21 - see undefined flags for BTx insn
22 - user/kernel PUSHL/POPL in helper.c 22 - user/kernel PUSHL/POPL in helper.c
1 /** 1 /**
2 - * 2 + *
3 * aes.c - integrated in QEMU by Fabrice Bellard from the OpenSSL project. 3 * aes.c - integrated in QEMU by Fabrice Bellard from the OpenSSL project.
4 */ 4 */
5 /* 5 /*
@@ -1267,7 +1267,7 @@ void AES_decrypt(const unsigned char *in, unsigned char *out, @@ -1267,7 +1267,7 @@ void AES_decrypt(const unsigned char *in, unsigned char *out,
1267 1267
1268 void AES_cbc_encrypt(const unsigned char *in, unsigned char *out, 1268 void AES_cbc_encrypt(const unsigned char *in, unsigned char *out,
1269 const unsigned long length, const AES_KEY *key, 1269 const unsigned long length, const AES_KEY *key,
1270 - unsigned char *ivec, const int enc) 1270 + unsigned char *ivec, const int enc)
1271 { 1271 {
1272 1272
1273 unsigned long n; 1273 unsigned long n;
@@ -1294,7 +1294,7 @@ void AES_cbc_encrypt(const unsigned char *in, unsigned char *out, @@ -1294,7 +1294,7 @@ void AES_cbc_encrypt(const unsigned char *in, unsigned char *out,
1294 AES_encrypt(tmp, tmp, key); 1294 AES_encrypt(tmp, tmp, key);
1295 memcpy(out, tmp, AES_BLOCK_SIZE); 1295 memcpy(out, tmp, AES_BLOCK_SIZE);
1296 memcpy(ivec, tmp, AES_BLOCK_SIZE); 1296 memcpy(ivec, tmp, AES_BLOCK_SIZE);
1297 - } 1297 + }
1298 } else { 1298 } else {
1299 while (len >= AES_BLOCK_SIZE) { 1299 while (len >= AES_BLOCK_SIZE) {
1300 memcpy(tmp, in, AES_BLOCK_SIZE); 1300 memcpy(tmp, in, AES_BLOCK_SIZE);
@@ -1312,6 +1312,6 @@ void AES_cbc_encrypt(const unsigned char *in, unsigned char *out, @@ -1312,6 +1312,6 @@ void AES_cbc_encrypt(const unsigned char *in, unsigned char *out,
1312 for(n=0; n < len; ++n) 1312 for(n=0; n < len; ++n)
1313 out[n] = tmp[n] ^ ivec[n]; 1313 out[n] = tmp[n] ^ ivec[n];
1314 memcpy(ivec, tmp, AES_BLOCK_SIZE); 1314 memcpy(ivec, tmp, AES_BLOCK_SIZE);
1315 - } 1315 + }
1316 } 1316 }
1317 } 1317 }
alpha-dis.c
@@ -374,7 +374,7 @@ const struct alpha_operand alpha_operands[] = @@ -374,7 +374,7 @@ const struct alpha_operand alpha_operands[] =
374 374
375 /* The signed "23-bit" aligned displacement of Branch format insns */ 375 /* The signed "23-bit" aligned displacement of Branch format insns */
376 #define BDISP (MDISP + 1) 376 #define BDISP (MDISP + 1)
377 - { 21, 0, BFD_RELOC_23_PCREL_S2, 377 + { 21, 0, BFD_RELOC_23_PCREL_S2,
378 AXP_OPERAND_RELATIVE, insert_bdisp, extract_bdisp }, 378 AXP_OPERAND_RELATIVE, insert_bdisp, extract_bdisp },
379 379
380 /* The 26-bit PALcode function */ 380 /* The 26-bit PALcode function */
arm-dis.c
@@ -4,17 +4,17 @@ @@ -4,17 +4,17 @@
4 Contributed by Richard Earnshaw (rwe@pegasus.esprit.ec.org) 4 Contributed by Richard Earnshaw (rwe@pegasus.esprit.ec.org)
5 Modification by James G. Smith (jsmith@cygnus.co.uk) 5 Modification by James G. Smith (jsmith@cygnus.co.uk)
6 6
7 -This file is part of libopcodes. 7 +This file is part of libopcodes.
8 8
9 This program is free software; you can redistribute it and/or modify it under 9 This program is free software; you can redistribute it and/or modify it under
10 the terms of the GNU General Public License as published by the Free 10 the terms of the GNU General Public License as published by the Free
11 Software Foundation; either version 2 of the License, or (at your option) 11 Software Foundation; either version 2 of the License, or (at your option)
12 -any later version. 12 +any later version.
13 13
14 This program is distributed in the hope that it will be useful, but WITHOUT 14 This program is distributed in the hope that it will be useful, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
17 -more details. 17 +more details.
18 18
19 You should have received a copy of the GNU General Public License 19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software 20 along with this program; if not, write to the Free Software
@@ -34,7 +34,7 @@ struct thumb_opcode @@ -34,7 +34,7 @@ struct thumb_opcode
34 }; 34 };
35 35
36 /* format of the assembler string : 36 /* format of the assembler string :
37 - 37 +
38 %% % 38 %% %
39 %<bitfield>d print the bitfield in decimal 39 %<bitfield>d print the bitfield in decimal
40 %<bitfield>x print the bitfield in hex 40 %<bitfield>x print the bitfield in hex
@@ -104,7 +104,7 @@ static struct arm_opcode arm_opcodes[] = @@ -104,7 +104,7 @@ static struct arm_opcode arm_opcodes[] =
104 {0x0c400000, 0x0ff00fff, "mar%c\tacc0, %12-15r, %16-19r"}, 104 {0x0c400000, 0x0ff00fff, "mar%c\tacc0, %12-15r, %16-19r"},
105 {0x0c500000, 0x0ff00fff, "mra%c\t%12-15r, %16-19r, acc0"}, 105 {0x0c500000, 0x0ff00fff, "mra%c\t%12-15r, %16-19r, acc0"},
106 {0xf450f000, 0xfc70f000, "pld\t%a"}, 106 {0xf450f000, 0xfc70f000, "pld\t%a"},
107 - 107 +
108 /* V5 Instructions. */ 108 /* V5 Instructions. */
109 {0xe1200070, 0xfff000f0, "bkpt\t0x%16-19X%12-15X%8-11X%0-3X"}, 109 {0xe1200070, 0xfff000f0, "bkpt\t0x%16-19X%12-15X%8-11X%0-3X"},
110 {0xfa000000, 0xfe000000, "blx\t%B"}, 110 {0xfa000000, 0xfe000000, "blx\t%B"},
@@ -116,7 +116,7 @@ static struct arm_opcode arm_opcodes[] = @@ -116,7 +116,7 @@ static struct arm_opcode arm_opcodes[] =
116 {0xfe000010, 0xff100010, "mcr2\t%8-11d, %21-23d, %12-15r, cr%16-19d, cr%0-3d, {%5-7d}"}, 116 {0xfe000010, 0xff100010, "mcr2\t%8-11d, %21-23d, %12-15r, cr%16-19d, cr%0-3d, {%5-7d}"},
117 {0xfe100010, 0xff100010, "mrc2\t%8-11d, %21-23d, %12-15r, cr%16-19d, cr%0-3d, {%5-7d}"}, 117 {0xfe100010, 0xff100010, "mrc2\t%8-11d, %21-23d, %12-15r, cr%16-19d, cr%0-3d, {%5-7d}"},
118 118
119 - /* V5E "El Segundo" Instructions. */ 119 + /* V5E "El Segundo" Instructions. */
120 {0x000000d0, 0x0e1000f0, "ldr%cd\t%12-15r, %s"}, 120 {0x000000d0, 0x0e1000f0, "ldr%cd\t%12-15r, %s"},
121 {0x000000f0, 0x0e1000f0, "str%cd\t%12-15r, %s"}, 121 {0x000000f0, 0x0e1000f0, "str%cd\t%12-15r, %s"},
122 {0x01000080, 0x0ff000f0, "smlabb%c\t%16-19r, %0-3r, %8-11r, %12-15r"}, 122 {0x01000080, 0x0ff000f0, "smlabb%c\t%16-19r, %0-3r, %8-11r, %12-15r"},
@@ -303,7 +303,7 @@ static struct arm_opcode arm_opcodes[] = @@ -303,7 +303,7 @@ static struct arm_opcode arm_opcodes[] =
303 {0x0d100400, 0x0f500f00, "cfldrs%c\tmvf%12-15d, %A"}, 303 {0x0d100400, 0x0f500f00, "cfldrs%c\tmvf%12-15d, %A"},
304 {0x0c100400, 0x0f500f00, "cfldrs%c\tmvf%12-15d, %A"}, 304 {0x0c100400, 0x0f500f00, "cfldrs%c\tmvf%12-15d, %A"},
305 {0x0d500400, 0x0f500f00, "cfldrd%c\tmvd%12-15d, %A"}, 305 {0x0d500400, 0x0f500f00, "cfldrd%c\tmvd%12-15d, %A"},
306 - {0x0c500400, 0x0f500f00, "cfldrd%c\tmvd%12-15d, %A"}, 306 + {0x0c500400, 0x0f500f00, "cfldrd%c\tmvd%12-15d, %A"},
307 {0x0d100500, 0x0f500f00, "cfldr32%c\tmvfx%12-15d, %A"}, 307 {0x0d100500, 0x0f500f00, "cfldr32%c\tmvfx%12-15d, %A"},
308 {0x0c100500, 0x0f500f00, "cfldr32%c\tmvfx%12-15d, %A"}, 308 {0x0c100500, 0x0f500f00, "cfldr32%c\tmvfx%12-15d, %A"},
309 {0x0d500500, 0x0f500f00, "cfldr64%c\tmvdx%12-15d, %A"}, 309 {0x0d500500, 0x0f500f00, "cfldr64%c\tmvdx%12-15d, %A"},
@@ -571,7 +571,7 @@ static boolean force_thumb = false; @@ -571,7 +571,7 @@ static boolean force_thumb = false;
571 static char * arm_fp_const[] = 571 static char * arm_fp_const[] =
572 {"0.0", "1.0", "2.0", "3.0", "4.0", "5.0", "0.5", "10.0"}; 572 {"0.0", "1.0", "2.0", "3.0", "4.0", "5.0", "0.5", "10.0"};
573 573
574 -static char * arm_shift[] = 574 +static char * arm_shift[] =
575 {"lsl", "lsr", "asr", "ror"}; 575 {"lsl", "lsr", "asr", "ror"};
576 576
577 /* Forward declarations. */ 577 /* Forward declarations. */
@@ -621,14 +621,14 @@ arm_decode_shift (given, func, stream) @@ -621,14 +621,14 @@ arm_decode_shift (given, func, stream)
621 void * stream; 621 void * stream;
622 { 622 {
623 func (stream, "%s", arm_regnames[given & 0xf]); 623 func (stream, "%s", arm_regnames[given & 0xf]);
624 - 624 +
625 if ((given & 0xff0) != 0) 625 if ((given & 0xff0) != 0)
626 { 626 {
627 if ((given & 0x10) == 0) 627 if ((given & 0x10) == 0)
628 { 628 {
629 int amount = (given & 0xf80) >> 7; 629 int amount = (given & 0xf80) >> 7;
630 int shift = (given & 0x60) >> 5; 630 int shift = (given & 0x60) >> 5;
631 - 631 +
632 if (amount == 0) 632 if (amount == 0)
633 { 633 {
634 if (shift == 3) 634 if (shift == 3)
@@ -636,10 +636,10 @@ arm_decode_shift (given, func, stream) @@ -636,10 +636,10 @@ arm_decode_shift (given, func, stream)
636 func (stream, ", rrx"); 636 func (stream, ", rrx");
637 return; 637 return;
638 } 638 }
639 - 639 +
640 amount = 32; 640 amount = 32;
641 } 641 }
642 - 642 +
643 func (stream, ", %s #%d", arm_shift[shift], amount); 643 func (stream, ", %s #%d", arm_shift[shift], amount);
644 } 644 }
645 else 645 else
@@ -666,7 +666,7 @@ print_insn_arm1 (pc, info, given) @@ -666,7 +666,7 @@ print_insn_arm1 (pc, info, given)
666 if ((given & insn->mask) == insn->value) 666 if ((given & insn->mask) == insn->value)
667 { 667 {
668 char * c; 668 char * c;
669 - 669 +
670 for (c = insn->assembler; *c; c++) 670 for (c = insn->assembler; *c; c++)
671 { 671 {
672 if (*c == '%') 672 if (*c == '%')
@@ -682,14 +682,14 @@ print_insn_arm1 (pc, info, given) @@ -682,14 +682,14 @@ print_insn_arm1 (pc, info, given)
682 && ((given & 0x02000000) == 0)) 682 && ((given & 0x02000000) == 0))
683 { 683 {
684 int offset = given & 0xfff; 684 int offset = given & 0xfff;
685 - 685 +
686 func (stream, "[pc"); 686 func (stream, "[pc");
687 - 687 +
688 if (given & 0x01000000) 688 if (given & 0x01000000)
689 { 689 {
690 if ((given & 0x00800000) == 0) 690 if ((given & 0x00800000) == 0)
691 offset = - offset; 691 offset = - offset;
692 - 692 +
693 /* Pre-indexed. */ 693 /* Pre-indexed. */
694 func (stream, ", #%d]", offset); 694 func (stream, ", #%d]", offset);
695 695
@@ -710,13 +710,13 @@ print_insn_arm1 (pc, info, given) @@ -710,13 +710,13 @@ print_insn_arm1 (pc, info, given)
710 /* ie ignore the offset. */ 710 /* ie ignore the offset. */
711 offset = pc + 8; 711 offset = pc + 8;
712 } 712 }
713 - 713 +
714 func (stream, "\t; "); 714 func (stream, "\t; ");
715 info->print_address_func (offset, info); 715 info->print_address_func (offset, info);
716 } 716 }
717 else 717 else
718 { 718 {
719 - func (stream, "[%s", 719 + func (stream, "[%s",
720 arm_regnames[(given >> 16) & 0xf]); 720 arm_regnames[(given >> 16) & 0xf]);
721 if ((given & 0x01000000) != 0) 721 if ((given & 0x01000000) != 0)
722 { 722 {
@@ -736,7 +736,7 @@ print_insn_arm1 (pc, info, given) @@ -736,7 +736,7 @@ print_insn_arm1 (pc, info, given)
736 arm_decode_shift (given, func, stream); 736 arm_decode_shift (given, func, stream);
737 } 737 }
738 738
739 - func (stream, "]%s", 739 + func (stream, "]%s",
740 ((given & 0x00200000) != 0) ? "!" : ""); 740 ((given & 0x00200000) != 0) ? "!" : "");
741 } 741 }
742 else 742 else
@@ -748,13 +748,13 @@ print_insn_arm1 (pc, info, given) @@ -748,13 +748,13 @@ print_insn_arm1 (pc, info, given)
748 func (stream, "], %s#%d", 748 func (stream, "], %s#%d",
749 (((given & 0x00800000) == 0) 749 (((given & 0x00800000) == 0)
750 ? "-" : ""), offset); 750 ? "-" : ""), offset);
751 - else 751 + else
752 func (stream, "]"); 752 func (stream, "]");
753 } 753 }
754 else 754 else
755 { 755 {
756 func (stream, "], %s", 756 func (stream, "], %s",
757 - (((given & 0x00800000) == 0) 757 + (((given & 0x00800000) == 0)
758 ? "-" : "")); 758 ? "-" : ""));
759 arm_decode_shift (given, func, stream); 759 arm_decode_shift (given, func, stream);
760 } 760 }
@@ -767,18 +767,18 @@ print_insn_arm1 (pc, info, given) @@ -767,18 +767,18 @@ print_insn_arm1 (pc, info, given)
767 { 767 {
768 /* PC relative with immediate offset. */ 768 /* PC relative with immediate offset. */
769 int offset = ((given & 0xf00) >> 4) | (given & 0xf); 769 int offset = ((given & 0xf00) >> 4) | (given & 0xf);
770 - 770 +
771 if ((given & 0x00800000) == 0) 771 if ((given & 0x00800000) == 0)
772 offset = -offset; 772 offset = -offset;
773 - 773 +
774 func (stream, "[pc, #%d]\t; ", offset); 774 func (stream, "[pc, #%d]\t; ", offset);
775 - 775 +
776 (*info->print_address_func) 776 (*info->print_address_func)
777 (offset + pc + 8, info); 777 (offset + pc + 8, info);
778 } 778 }
779 else 779 else
780 { 780 {
781 - func (stream, "[%s", 781 + func (stream, "[%s",
782 arm_regnames[(given >> 16) & 0xf]); 782 arm_regnames[(given >> 16) & 0xf]);
783 if ((given & 0x01000000) != 0) 783 if ((given & 0x01000000) != 0)
784 { 784 {
@@ -801,7 +801,7 @@ print_insn_arm1 (pc, info, given) @@ -801,7 +801,7 @@ print_insn_arm1 (pc, info, given)
801 arm_regnames[given & 0xf]); 801 arm_regnames[given & 0xf]);
802 } 802 }
803 803
804 - func (stream, "]%s", 804 + func (stream, "]%s",
805 ((given & 0x00200000) != 0) ? "!" : ""); 805 ((given & 0x00200000) != 0) ? "!" : "");
806 } 806 }
807 else 807 else
@@ -815,7 +815,7 @@ print_insn_arm1 (pc, info, given) @@ -815,7 +815,7 @@ print_insn_arm1 (pc, info, given)
815 func (stream, "], %s#%d", 815 func (stream, "], %s#%d",
816 (((given & 0x00800000) == 0) 816 (((given & 0x00800000) == 0)
817 ? "-" : ""), offset); 817 ? "-" : ""), offset);
818 - else 818 + else
819 func (stream, "]"); 819 func (stream, "]");
820 } 820 }
821 else 821 else
@@ -829,7 +829,7 @@ print_insn_arm1 (pc, info, given) @@ -829,7 +829,7 @@ print_insn_arm1 (pc, info, given)
829 } 829 }
830 } 830 }
831 break; 831 break;
832 - 832 +
833 case 'b': 833 case 'b':
834 (*info->print_address_func) 834 (*info->print_address_func)
835 (BDISP (given) * 4 + pc + 8, info); 835 (BDISP (given) * 4 + pc + 8, info);
@@ -911,7 +911,7 @@ print_insn_arm1 (pc, info, given) @@ -911,7 +911,7 @@ print_insn_arm1 (pc, info, given)
911 { 911 {
912 bfd_vma address; 912 bfd_vma address;
913 bfd_vma offset = 0; 913 bfd_vma offset = 0;
914 - 914 +
915 if (given & 0x00800000) 915 if (given & 0x00800000)
916 /* Is signed, hi bits should be ones. */ 916 /* Is signed, hi bits should be ones. */
917 offset = (-1) ^ 0x00ffffff; 917 offset = (-1) ^ 0x00ffffff;
@@ -920,7 +920,7 @@ print_insn_arm1 (pc, info, given) @@ -920,7 +920,7 @@ print_insn_arm1 (pc, info, given)
920 offset += given & 0x00ffffff; 920 offset += given & 0x00ffffff;
921 offset <<= 2; 921 offset <<= 2;
922 address = offset + pc + 8; 922 address = offset + pc + 8;
923 - 923 +
924 if (given & 0x01000000) 924 if (given & 0x01000000)
925 /* H bit allows addressing to 2-byte boundaries. */ 925 /* H bit allows addressing to 2-byte boundaries. */
926 address += 2; 926 address += 2;
@@ -976,7 +976,7 @@ print_insn_arm1 (pc, info, given) @@ -976,7 +976,7 @@ print_insn_arm1 (pc, info, given)
976 func (stream, "3"); 976 func (stream, "3");
977 } 977 }
978 break; 978 break;
979 - 979 +
980 case 'P': 980 case 'P':
981 switch (given & 0x00080080) 981 switch (given & 0x00080080)
982 { 982 {
@@ -1028,7 +1028,7 @@ print_insn_arm1 (pc, info, given) @@ -1028,7 +1028,7 @@ print_insn_arm1 (pc, info, given)
1028 } 1028 }
1029 break; 1029 break;
1030 1030
1031 - case '0': case '1': case '2': case '3': case '4': 1031 + case '0': case '1': case '2': case '3': case '4':
1032 case '5': case '6': case '7': case '8': case '9': 1032 case '5': case '6': case '7': case '8': case '9':
1033 { 1033 {
1034 int bitstart = *c++ - '0'; 1034 int bitstart = *c++ - '0';
@@ -1040,44 +1040,44 @@ print_insn_arm1 (pc, info, given) @@ -1040,44 +1040,44 @@ print_insn_arm1 (pc, info, given)
1040 { 1040 {
1041 case '-': 1041 case '-':
1042 c++; 1042 c++;
1043 - 1043 +
1044 while (*c >= '0' && *c <= '9') 1044 while (*c >= '0' && *c <= '9')
1045 bitend = (bitend * 10) + *c++ - '0'; 1045 bitend = (bitend * 10) + *c++ - '0';
1046 - 1046 +
1047 if (!bitend) 1047 if (!bitend)
1048 abort (); 1048 abort ();
1049 - 1049 +
1050 switch (*c) 1050 switch (*c)
1051 { 1051 {
1052 case 'r': 1052 case 'r':
1053 { 1053 {
1054 long reg; 1054 long reg;
1055 - 1055 +
1056 reg = given >> bitstart; 1056 reg = given >> bitstart;
1057 reg &= (2 << (bitend - bitstart)) - 1; 1057 reg &= (2 << (bitend - bitstart)) - 1;
1058 - 1058 +
1059 func (stream, "%s", arm_regnames[reg]); 1059 func (stream, "%s", arm_regnames[reg]);
1060 } 1060 }
1061 break; 1061 break;
1062 case 'd': 1062 case 'd':
1063 { 1063 {
1064 long reg; 1064 long reg;
1065 - 1065 +
1066 reg = given >> bitstart; 1066 reg = given >> bitstart;
1067 reg &= (2 << (bitend - bitstart)) - 1; 1067 reg &= (2 << (bitend - bitstart)) - 1;
1068 - 1068 +
1069 func (stream, "%d", reg); 1069 func (stream, "%d", reg);
1070 } 1070 }
1071 break; 1071 break;
1072 case 'x': 1072 case 'x':
1073 { 1073 {
1074 long reg; 1074 long reg;
1075 - 1075 +
1076 reg = given >> bitstart; 1076 reg = given >> bitstart;
1077 reg &= (2 << (bitend - bitstart)) - 1; 1077 reg &= (2 << (bitend - bitstart)) - 1;
1078 - 1078 +
1079 func (stream, "0x%08x", reg); 1079 func (stream, "0x%08x", reg);
1080 - 1080 +
1081 /* Some SWI instructions have special 1081 /* Some SWI instructions have special
1082 meanings. */ 1082 meanings. */
1083 if ((given & 0x0fffffff) == 0x0FF00000) 1083 if ((given & 0x0fffffff) == 0x0FF00000)
@@ -1089,20 +1089,20 @@ print_insn_arm1 (pc, info, given) @@ -1089,20 +1089,20 @@ print_insn_arm1 (pc, info, given)
1089 case 'X': 1089 case 'X':
1090 { 1090 {
1091 long reg; 1091 long reg;
1092 - 1092 +
1093 reg = given >> bitstart; 1093 reg = given >> bitstart;
1094 reg &= (2 << (bitend - bitstart)) - 1; 1094 reg &= (2 << (bitend - bitstart)) - 1;
1095 - 1095 +
1096 func (stream, "%01x", reg & 0xf); 1096 func (stream, "%01x", reg & 0xf);
1097 } 1097 }
1098 break; 1098 break;
1099 case 'f': 1099 case 'f':
1100 { 1100 {
1101 long reg; 1101 long reg;
1102 - 1102 +
1103 reg = given >> bitstart; 1103 reg = given >> bitstart;
1104 reg &= (2 << (bitend - bitstart)) - 1; 1104 reg &= (2 << (bitend - bitstart)) - 1;
1105 - 1105 +
1106 if (reg > 7) 1106 if (reg > 7)
1107 func (stream, "#%s", 1107 func (stream, "#%s",
1108 arm_fp_const[reg & 7]); 1108 arm_fp_const[reg & 7]);
@@ -1163,7 +1163,7 @@ print_insn_arm1 (pc, info, given) @@ -1163,7 +1163,7 @@ print_insn_arm1 (pc, info, given)
1163 } 1163 }
1164 break; 1164 break;
1165 1165
1166 - 1166 +
1167 default: 1167 default:
1168 abort (); 1168 abort ();
1169 } 1169 }
@@ -1252,7 +1252,7 @@ print_insn_thumb (pc, info, given) @@ -1252,7 +1252,7 @@ print_insn_thumb (pc, info, given)
1252 if (!*c) /* Check for empty (not NULL) assembler string. */ 1252 if (!*c) /* Check for empty (not NULL) assembler string. */
1253 { 1253 {
1254 long offset; 1254 long offset;
1255 - 1255 +
1256 info->bytes_per_chunk = 4; 1256 info->bytes_per_chunk = 4;
1257 info->bytes_per_line = 4; 1257 info->bytes_per_line = 4;
1258 1258
@@ -1274,16 +1274,16 @@ print_insn_thumb (pc, info, given) @@ -1274,16 +1274,16 @@ print_insn_thumb (pc, info, given)
1274 { 1274 {
1275 info->bytes_per_chunk = 2; 1275 info->bytes_per_chunk = 2;
1276 info->bytes_per_line = 4; 1276 info->bytes_per_line = 4;
1277 - 1277 +
1278 given &= 0xffff; 1278 given &= 0xffff;
1279 - 1279 +
1280 for (; *c; c++) 1280 for (; *c; c++)
1281 { 1281 {
1282 if (*c == '%') 1282 if (*c == '%')
1283 { 1283 {
1284 int domaskpc = 0; 1284 int domaskpc = 0;
1285 int domasklr = 0; 1285 int domasklr = 0;
1286 - 1286 +
1287 switch (*++c) 1287 switch (*++c)
1288 { 1288 {
1289 case '%': 1289 case '%':
@@ -1293,11 +1293,11 @@ print_insn_thumb (pc, info, given) @@ -1293,11 +1293,11 @@ print_insn_thumb (pc, info, given)
1293 case 'S': 1293 case 'S':
1294 { 1294 {
1295 long reg; 1295 long reg;
1296 - 1296 +
1297 reg = (given >> 3) & 0x7; 1297 reg = (given >> 3) & 0x7;
1298 if (given & (1 << 6)) 1298 if (given & (1 << 6))
1299 reg += 8; 1299 reg += 8;
1300 - 1300 +
1301 func (stream, "%s", arm_regnames[reg]); 1301 func (stream, "%s", arm_regnames[reg]);
1302 } 1302 }
1303 break; 1303 break;
@@ -1305,11 +1305,11 @@ print_insn_thumb (pc, info, given) @@ -1305,11 +1305,11 @@ print_insn_thumb (pc, info, given)
1305 case 'D': 1305 case 'D':
1306 { 1306 {
1307 long reg; 1307 long reg;
1308 - 1308 +
1309 reg = given & 0x7; 1309 reg = given & 0x7;
1310 if (given & (1 << 7)) 1310 if (given & (1 << 7))
1311 reg += 8; 1311 reg += 8;
1312 - 1312 +
1313 func (stream, "%s", arm_regnames[reg]); 1313 func (stream, "%s", arm_regnames[reg]);
1314 } 1314 }
1315 break; 1315 break;
@@ -1331,9 +1331,9 @@ print_insn_thumb (pc, info, given) @@ -1331,9 +1331,9 @@ print_insn_thumb (pc, info, given)
1331 { 1331 {
1332 int started = 0; 1332 int started = 0;
1333 int reg; 1333 int reg;
1334 - 1334 +
1335 func (stream, "{"); 1335 func (stream, "{");
1336 - 1336 +
1337 /* It would be nice if we could spot 1337 /* It would be nice if we could spot
1338 ranges, and generate the rS-rE format: */ 1338 ranges, and generate the rS-rE format: */
1339 for (reg = 0; (reg < 8); reg++) 1339 for (reg = 0; (reg < 8); reg++)
@@ -1365,12 +1365,12 @@ print_insn_thumb (pc, info, given) @@ -1365,12 +1365,12 @@ print_insn_thumb (pc, info, given)
1365 break; 1365 break;
1366 1366
1367 1367
1368 - case '0': case '1': case '2': case '3': case '4': 1368 + case '0': case '1': case '2': case '3': case '4':
1369 case '5': case '6': case '7': case '8': case '9': 1369 case '5': case '6': case '7': case '8': case '9':
1370 { 1370 {
1371 int bitstart = *c++ - '0'; 1371 int bitstart = *c++ - '0';
1372 int bitend = 0; 1372 int bitend = 0;
1373 - 1373 +
1374 while (*c >= '0' && *c <= '9') 1374 while (*c >= '0' && *c <= '9')
1375 bitstart = (bitstart * 10) + *c++ - '0'; 1375 bitstart = (bitstart * 10) + *c++ - '0';
1376 1376
@@ -1379,7 +1379,7 @@ print_insn_thumb (pc, info, given) @@ -1379,7 +1379,7 @@ print_insn_thumb (pc, info, given)
1379 case '-': 1379 case '-':
1380 { 1380 {
1381 long reg; 1381 long reg;
1382 - 1382 +
1383 c++; 1383 c++;
1384 while (*c >= '0' && *c <= '9') 1384 while (*c >= '0' && *c <= '9')
1385 bitend = (bitend * 10) + *c++ - '0'; 1385 bitend = (bitend * 10) + *c++ - '0';
@@ -1478,11 +1478,11 @@ parse_arm_disassembler_option (option) @@ -1478,11 +1478,11 @@ parse_arm_disassembler_option (option)
1478 { 1478 {
1479 if (option == NULL) 1479 if (option == NULL)
1480 return; 1480 return;
1481 - 1481 +
1482 if (strneq (option, "reg-names-", 10)) 1482 if (strneq (option, "reg-names-", 10))
1483 { 1483 {
1484 int i; 1484 int i;
1485 - 1485 +
1486 option += 10; 1486 option += 10;
1487 1487
1488 for (i = NUM_ARM_REGNAMES; i--;) 1488 for (i = NUM_ARM_REGNAMES; i--;)
@@ -1491,7 +1491,7 @@ parse_arm_disassembler_option (option) @@ -1491,7 +1491,7 @@ parse_arm_disassembler_option (option)
1491 regname_selected = i; 1491 regname_selected = i;
1492 break; 1492 break;
1493 } 1493 }
1494 - 1494 +
1495 if (i < 0) 1495 if (i < 0)
1496 fprintf (stderr, _("Unrecognised register name set: %s\n"), option); 1496 fprintf (stderr, _("Unrecognised register name set: %s\n"), option);
1497 } 1497 }
@@ -1501,7 +1501,7 @@ parse_arm_disassembler_option (option) @@ -1501,7 +1501,7 @@ parse_arm_disassembler_option (option)
1501 force_thumb = 0; 1501 force_thumb = 0;
1502 else 1502 else
1503 fprintf (stderr, _("Unrecognised disassembler option: %s\n"), option); 1503 fprintf (stderr, _("Unrecognised disassembler option: %s\n"), option);
1504 - 1504 +
1505 return; 1505 return;
1506 } 1506 }
1507 1507
@@ -1512,7 +1512,7 @@ parse_disassembler_options (options) @@ -1512,7 +1512,7 @@ parse_disassembler_options (options)
1512 char * options; 1512 char * options;
1513 { 1513 {
1514 char * space; 1514 char * space;
1515 - 1515 +
1516 if (options == NULL) 1516 if (options == NULL)
1517 return; 1517 return;
1518 1518
@@ -1550,25 +1550,25 @@ print_insn_arm (pc, info) @@ -1550,25 +1550,25 @@ print_insn_arm (pc, info)
1550 if (info->disassembler_options) 1550 if (info->disassembler_options)
1551 { 1551 {
1552 parse_disassembler_options (info->disassembler_options); 1552 parse_disassembler_options (info->disassembler_options);
1553 - 1553 +
1554 /* To avoid repeated parsing of these options, we remove them here. */ 1554 /* To avoid repeated parsing of these options, we remove them here. */
1555 info->disassembler_options = NULL; 1555 info->disassembler_options = NULL;
1556 } 1556 }
1557 - 1557 +
1558 is_thumb = force_thumb; 1558 is_thumb = force_thumb;
1559 if (pc & 1) 1559 if (pc & 1)
1560 { 1560 {
1561 is_thumb = 1; 1561 is_thumb = 1;
1562 pc &= ~(bfd_vma) 1; 1562 pc &= ~(bfd_vma) 1;
1563 } 1563 }
1564 - 1564 +
1565 #if 0 1565 #if 0
1566 if (!is_thumb && info->symbols != NULL) 1566 if (!is_thumb && info->symbols != NULL)
1567 { 1567 {
1568 if (bfd_asymbol_flavour (*info->symbols) == bfd_target_coff_flavour) 1568 if (bfd_asymbol_flavour (*info->symbols) == bfd_target_coff_flavour)
1569 { 1569 {
1570 coff_symbol_type * cs; 1570 coff_symbol_type * cs;
1571 - 1571 +
1572 cs = coffsymbol (*info->symbols); 1572 cs = coffsymbol (*info->symbols);
1573 is_thumb = ( cs->native->u.syment.n_sclass == C_THUMBEXT 1573 is_thumb = ( cs->native->u.syment.n_sclass == C_THUMBEXT
1574 || cs->native->u.syment.n_sclass == C_THUMBSTAT 1574 || cs->native->u.syment.n_sclass == C_THUMBSTAT
@@ -1580,15 +1580,15 @@ print_insn_arm (pc, info) @@ -1580,15 +1580,15 @@ print_insn_arm (pc, info)
1580 { 1580 {
1581 elf_symbol_type * es; 1581 elf_symbol_type * es;
1582 unsigned int type; 1582 unsigned int type;
1583 - 1583 +
1584 es = *(elf_symbol_type **)(info->symbols); 1584 es = *(elf_symbol_type **)(info->symbols);
1585 type = ELF_ST_TYPE (es->internal_elf_sym.st_info); 1585 type = ELF_ST_TYPE (es->internal_elf_sym.st_info);
1586 - 1586 +
1587 is_thumb = (type == STT_ARM_TFUNC) || (type == STT_ARM_16BIT); 1587 is_thumb = (type == STT_ARM_TFUNC) || (type == STT_ARM_16BIT);
1588 } 1588 }
1589 } 1589 }
1590 #endif 1590 #endif
1591 - 1591 +
1592 little = (info->endian == BFD_ENDIAN_LITTLE); 1592 little = (info->endian == BFD_ENDIAN_LITTLE);
1593 info->bytes_per_chunk = 4; 1593 info->bytes_per_chunk = 4;
1594 info->display_endian = little ? BFD_ENDIAN_LITTLE : BFD_ENDIAN_BIG; 1594 info->display_endian = little ? BFD_ENDIAN_LITTLE : BFD_ENDIAN_BIG;
@@ -1599,17 +1599,17 @@ print_insn_arm (pc, info) @@ -1599,17 +1599,17 @@ print_insn_arm (pc, info)
1599 if (status != 0 && is_thumb) 1599 if (status != 0 && is_thumb)
1600 { 1600 {
1601 info->bytes_per_chunk = 2; 1601 info->bytes_per_chunk = 2;
1602 - 1602 +
1603 status = info->read_memory_func (pc, (bfd_byte *) b, 2, info); 1603 status = info->read_memory_func (pc, (bfd_byte *) b, 2, info);
1604 b[3] = b[2] = 0; 1604 b[3] = b[2] = 0;
1605 } 1605 }
1606 - 1606 +
1607 if (status != 0) 1607 if (status != 0)
1608 { 1608 {
1609 info->memory_error_func (status, pc, info); 1609 info->memory_error_func (status, pc, info);
1610 return -1; 1610 return -1;
1611 } 1611 }
1612 - 1612 +
1613 given = (b[0]) | (b[1] << 8) | (b[2] << 16) | (b[3] << 24); 1613 given = (b[0]) | (b[1] << 8) | (b[2] << 16) | (b[3] << 24);
1614 } 1614 }
1615 else 1615 else
@@ -1621,13 +1621,13 @@ print_insn_arm (pc, info) @@ -1621,13 +1621,13 @@ print_insn_arm (pc, info)
1621 info->memory_error_func (status, pc, info); 1621 info->memory_error_func (status, pc, info);
1622 return -1; 1622 return -1;
1623 } 1623 }
1624 - 1624 +
1625 if (is_thumb) 1625 if (is_thumb)
1626 { 1626 {
1627 if (pc & 0x2) 1627 if (pc & 0x2)
1628 { 1628 {
1629 given = (b[2] << 8) | b[3]; 1629 given = (b[2] << 8) | b[3];
1630 - 1630 +
1631 status = info->read_memory_func 1631 status = info->read_memory_func
1632 ((pc + 4) & ~ 0x3, (bfd_byte *) b, 4, info); 1632 ((pc + 4) & ~ 0x3, (bfd_byte *) b, 4, info);
1633 if (status != 0) 1633 if (status != 0)
@@ -1635,7 +1635,7 @@ print_insn_arm (pc, info) @@ -1635,7 +1635,7 @@ print_insn_arm (pc, info)
1635 info->memory_error_func (status, pc + 4, info); 1635 info->memory_error_func (status, pc + 4, info);
1636 return -1; 1636 return -1;
1637 } 1637 }
1638 - 1638 +
1639 given |= (b[0] << 24) | (b[1] << 16); 1639 given |= (b[0] << 24) | (b[1] << 16);
1640 } 1640 }
1641 else 1641 else
@@ -1644,7 +1644,7 @@ print_insn_arm (pc, info) @@ -1644,7 +1644,7 @@ print_insn_arm (pc, info)
1644 else 1644 else
1645 given = (b[0] << 24) | (b[1] << 16) | (b[2] << 8) | (b[3]); 1645 given = (b[0] << 24) | (b[1] << 16) | (b[2] << 8) | (b[3]);
1646 } 1646 }
1647 - 1647 +
1648 if (info->flags & INSN_HAS_RELOC) 1648 if (info->flags & INSN_HAS_RELOC)
1649 /* If the instruction has a reloc associated with it, then 1649 /* If the instruction has a reloc associated with it, then
1650 the offset field in the instruction will actually be the 1650 the offset field in the instruction will actually be the
@@ -1668,7 +1668,7 @@ print_arm_disassembler_options (FILE * stream) @@ -1668,7 +1668,7 @@ print_arm_disassembler_options (FILE * stream)
1668 fprintf (stream, _("\n\ 1668 fprintf (stream, _("\n\
1669 The following ARM specific disassembler options are supported for use with\n\ 1669 The following ARM specific disassembler options are supported for use with\n\
1670 the -M switch:\n")); 1670 the -M switch:\n"));
1671 - 1671 +
1672 for (i = NUM_ARM_REGNAMES; i--;) 1672 for (i = NUM_ARM_REGNAMES; i--;)
1673 fprintf (stream, " reg-names-%s %*c%s\n", 1673 fprintf (stream, " reg-names-%s %*c%s\n",
1674 regnames[i].name, 1674 regnames[i].name,
arm-semi.c
1 /* 1 /*
2 * Arm "Angel" semihosting syscalls 2 * Arm "Angel" semihosting syscalls
3 - * 3 + *
4 * Copyright (c) 2005, 2007 CodeSourcery. 4 * Copyright (c) 2005, 2007 CodeSourcery.
5 * Written by Paul Brook. 5 * Written by Paul Brook.
6 * 6 *
@@ -194,7 +194,7 @@ uint32_t do_arm_semihosting(CPUState *env) @@ -194,7 +194,7 @@ uint32_t do_arm_semihosting(CPUState *env)
194 return STDOUT_FILENO; 194 return STDOUT_FILENO;
195 } 195 }
196 if (use_gdb_syscalls()) { 196 if (use_gdb_syscalls()) {
197 - gdb_do_syscall(arm_semi_cb, "open,%s,%x,1a4", ARG(0), 197 + gdb_do_syscall(arm_semi_cb, "open,%s,%x,1a4", ARG(0),
198 (int)ARG(2)+1, gdb_open_modeflags[ARG(1)]); 198 (int)ARG(2)+1, gdb_open_modeflags[ARG(1)]);
199 return env->regs[0]; 199 return env->regs[0];
200 } else { 200 } else {
@@ -283,7 +283,7 @@ uint32_t do_arm_semihosting(CPUState *env) @@ -283,7 +283,7 @@ uint32_t do_arm_semihosting(CPUState *env)
283 } 283 }
284 case SYS_FLEN: 284 case SYS_FLEN:
285 if (use_gdb_syscalls()) { 285 if (use_gdb_syscalls()) {
286 - gdb_do_syscall(arm_semi_flen_cb, "fstat,%x,%x", 286 + gdb_do_syscall(arm_semi_flen_cb, "fstat,%x,%x",
287 ARG(0), env->regs[13]-64); 287 ARG(0), env->regs[13]-64);
288 return env->regs[0]; 288 return env->regs[0];
289 } else { 289 } else {
@@ -401,7 +401,7 @@ uint32_t do_arm_semihosting(CPUState *env) @@ -401,7 +401,7 @@ uint32_t do_arm_semihosting(CPUState *env)
401 } 401 }
402 ts->heap_limit = limit; 402 ts->heap_limit = limit;
403 } 403 }
404 - 404 +
405 ptr = lock_user(ARG(0), 16, 0); 405 ptr = lock_user(ARG(0), 16, 0);
406 ptr[0] = tswap32(ts->heap_base); 406 ptr[0] = tswap32(ts->heap_base);
407 ptr[1] = tswap32(ts->heap_limit); 407 ptr[1] = tswap32(ts->heap_limit);
block-bochs.c
1 /* 1 /*
2 * Block driver for the various disk image formats used by Bochs 2 * Block driver for the various disk image formats used by Bochs
3 * Currently only for "growing" type in read-only mode 3 * Currently only for "growing" type in read-only mode
4 - * 4 + *
5 * Copyright (c) 2005 Alex Beregszaszi 5 * Copyright (c) 2005 Alex Beregszaszi
6 - * 6 + *
7 * Permission is hereby granted, free of charge, to any person obtaining a copy 7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal 8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights 9 * in the Software without restriction, including without limitation the rights
@@ -44,7 +44,7 @@ struct bochs_header_v1 { @@ -44,7 +44,7 @@ struct bochs_header_v1 {
44 char subtype[16]; // "Undoable" / "Volatile" / "Growing" 44 char subtype[16]; // "Undoable" / "Volatile" / "Growing"
45 uint32_t version; 45 uint32_t version;
46 uint32_t header; // size of header 46 uint32_t header; // size of header
47 - 47 +
48 union { 48 union {
49 struct { 49 struct {
50 uint32_t catalog; // num of entries 50 uint32_t catalog; // num of entries
@@ -64,7 +64,7 @@ struct bochs_header { @@ -64,7 +64,7 @@ struct bochs_header {
64 char subtype[16]; // "Undoable" / "Volatile" / "Growing" 64 char subtype[16]; // "Undoable" / "Volatile" / "Growing"
65 uint32_t version; 65 uint32_t version;
66 uint32_t header; // size of header 66 uint32_t header; // size of header
67 - 67 +
68 union { 68 union {
69 struct { 69 struct {
70 uint32_t catalog; // num of entries 70 uint32_t catalog; // num of entries
@@ -83,9 +83,9 @@ typedef struct BDRVBochsState { @@ -83,9 +83,9 @@ typedef struct BDRVBochsState {
83 83
84 uint32_t *catalog_bitmap; 84 uint32_t *catalog_bitmap;
85 int catalog_size; 85 int catalog_size;
86 - 86 +
87 int data_offset; 87 int data_offset;
88 - 88 +
89 int bitmap_blocks; 89 int bitmap_blocks;
90 int extent_blocks; 90 int extent_blocks;
91 int extent_size; 91 int extent_size;
@@ -94,7 +94,7 @@ typedef struct BDRVBochsState { @@ -94,7 +94,7 @@ typedef struct BDRVBochsState {
94 static int bochs_probe(const uint8_t *buf, int buf_size, const char *filename) 94 static int bochs_probe(const uint8_t *buf, int buf_size, const char *filename)
95 { 95 {
96 const struct bochs_header *bochs = (const void *)buf; 96 const struct bochs_header *bochs = (const void *)buf;
97 - 97 +
98 if (buf_size < HEADER_SIZE) 98 if (buf_size < HEADER_SIZE)
99 return 0; 99 return 0;
100 100
@@ -121,9 +121,9 @@ static int bochs_open(BlockDriverState *bs, const char *filename, int flags) @@ -121,9 +121,9 @@ static int bochs_open(BlockDriverState *bs, const char *filename, int flags)
121 if (fd < 0) 121 if (fd < 0)
122 return -1; 122 return -1;
123 } 123 }
124 - 124 +
125 bs->read_only = 1; // no write support yet 125 bs->read_only = 1; // no write support yet
126 - 126 +
127 s->fd = fd; 127 s->fd = fd;
128 128
129 if (read(fd, &bochs, sizeof(bochs)) != sizeof(bochs)) { 129 if (read(fd, &bochs, sizeof(bochs)) != sizeof(bochs)) {
@@ -161,7 +161,7 @@ static int bochs_open(BlockDriverState *bs, const char *filename, int flags) @@ -161,7 +161,7 @@ static int bochs_open(BlockDriverState *bs, const char *filename, int flags)
161 161
162 s->bitmap_blocks = 1 + (le32_to_cpu(bochs.extra.redolog.bitmap) - 1) / 512; 162 s->bitmap_blocks = 1 + (le32_to_cpu(bochs.extra.redolog.bitmap) - 1) / 512;
163 s->extent_blocks = 1 + (le32_to_cpu(bochs.extra.redolog.extent) - 1) / 512; 163 s->extent_blocks = 1 + (le32_to_cpu(bochs.extra.redolog.extent) - 1) / 512;
164 - 164 +
165 s->extent_size = le32_to_cpu(bochs.extra.redolog.extent); 165 s->extent_size = le32_to_cpu(bochs.extra.redolog.extent);
166 166
167 return 0; 167 return 0;
@@ -180,7 +180,7 @@ static inline int seek_to_sector(BlockDriverState *bs, int64_t sector_num) @@ -180,7 +180,7 @@ static inline int seek_to_sector(BlockDriverState *bs, int64_t sector_num)
180 // seek to sector 180 // seek to sector
181 extent_index = offset / s->extent_size; 181 extent_index = offset / s->extent_size;
182 extent_offset = (offset % s->extent_size) / 512; 182 extent_offset = (offset % s->extent_size) / 512;
183 - 183 +
184 if (s->catalog_bitmap[extent_index] == 0xffffffff) 184 if (s->catalog_bitmap[extent_index] == 0xffffffff)
185 { 185 {
186 // fprintf(stderr, "page not allocated [%x - %x:%x]\n", 186 // fprintf(stderr, "page not allocated [%x - %x:%x]\n",
@@ -191,17 +191,17 @@ static inline int seek_to_sector(BlockDriverState *bs, int64_t sector_num) @@ -191,17 +191,17 @@ static inline int seek_to_sector(BlockDriverState *bs, int64_t sector_num)
191 bitmap_offset = s->data_offset + (512 * s->catalog_bitmap[extent_index] * 191 bitmap_offset = s->data_offset + (512 * s->catalog_bitmap[extent_index] *
192 (s->extent_blocks + s->bitmap_blocks)); 192 (s->extent_blocks + s->bitmap_blocks));
193 block_offset = bitmap_offset + (512 * (s->bitmap_blocks + extent_offset)); 193 block_offset = bitmap_offset + (512 * (s->bitmap_blocks + extent_offset));
194 - 194 +
195 // fprintf(stderr, "sect: %x [ext i: %x o: %x] -> %x bitmap: %x block: %x\n", 195 // fprintf(stderr, "sect: %x [ext i: %x o: %x] -> %x bitmap: %x block: %x\n",
196 // sector_num, extent_index, extent_offset, 196 // sector_num, extent_index, extent_offset,
197 // le32_to_cpu(s->catalog_bitmap[extent_index]), 197 // le32_to_cpu(s->catalog_bitmap[extent_index]),
198 // bitmap_offset, block_offset); 198 // bitmap_offset, block_offset);
199 - 199 +
200 // read in bitmap for current extent 200 // read in bitmap for current extent
201 lseek(s->fd, bitmap_offset + (extent_offset / 8), SEEK_SET); 201 lseek(s->fd, bitmap_offset + (extent_offset / 8), SEEK_SET);
202 - 202 +
203 read(s->fd, &bitmap_entry, 1); 203 read(s->fd, &bitmap_entry, 1);
204 - 204 +
205 if (!((bitmap_entry >> (extent_offset % 8)) & 1)) 205 if (!((bitmap_entry >> (extent_offset % 8)) & 1))
206 { 206 {
207 // fprintf(stderr, "sector (%x) in bitmap not allocated\n", 207 // fprintf(stderr, "sector (%x) in bitmap not allocated\n",
@@ -210,11 +210,11 @@ static inline int seek_to_sector(BlockDriverState *bs, int64_t sector_num) @@ -210,11 +210,11 @@ static inline int seek_to_sector(BlockDriverState *bs, int64_t sector_num)
210 } 210 }
211 211
212 lseek(s->fd, block_offset, SEEK_SET); 212 lseek(s->fd, block_offset, SEEK_SET);
213 - 213 +
214 return 0; 214 return 0;
215 } 215 }
216 216
217 -static int bochs_read(BlockDriverState *bs, int64_t sector_num, 217 +static int bochs_read(BlockDriverState *bs, int64_t sector_num,
218 uint8_t *buf, int nb_sectors) 218 uint8_t *buf, int nb_sectors)
219 { 219 {
220 BDRVBochsState *s = bs->opaque; 220 BDRVBochsState *s = bs->opaque;
block-cloop.c
1 /* 1 /*
2 * QEMU Block driver for CLOOP images 2 * QEMU Block driver for CLOOP images
3 - * 3 + *
4 * Copyright (c) 2004 Johannes E. Schindelin 4 * Copyright (c) 2004 Johannes E. Schindelin
5 - * 5 + *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy 6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal 7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights 8 * in the Software without restriction, including without limitation the rights
@@ -96,7 +96,7 @@ cloop_close: @@ -96,7 +96,7 @@ cloop_close:
96 if(inflateInit(&s->zstream) != Z_OK) 96 if(inflateInit(&s->zstream) != Z_OK)
97 goto cloop_close; 97 goto cloop_close;
98 s->current_block=s->n_blocks; 98 s->current_block=s->n_blocks;
99 - 99 +
100 s->sectors_per_block = s->block_size/512; 100 s->sectors_per_block = s->block_size/512;
101 bs->total_sectors = s->n_blocks*s->sectors_per_block; 101 bs->total_sectors = s->n_blocks*s->sectors_per_block;
102 return 0; 102 return 0;
@@ -107,12 +107,12 @@ static inline int cloop_read_block(BDRVCloopState *s,int block_num) @@ -107,12 +107,12 @@ static inline int cloop_read_block(BDRVCloopState *s,int block_num)
107 if(s->current_block != block_num) { 107 if(s->current_block != block_num) {
108 int ret; 108 int ret;
109 uint32_t bytes = s->offsets[block_num+1]-s->offsets[block_num]; 109 uint32_t bytes = s->offsets[block_num+1]-s->offsets[block_num];
110 - 110 +
111 lseek(s->fd, s->offsets[block_num], SEEK_SET); 111 lseek(s->fd, s->offsets[block_num], SEEK_SET);
112 ret = read(s->fd, s->compressed_block, bytes); 112 ret = read(s->fd, s->compressed_block, bytes);
113 - if (ret != bytes) 113 + if (ret != bytes)
114 return -1; 114 return -1;
115 - 115 +
116 s->zstream.next_in = s->compressed_block; 116 s->zstream.next_in = s->compressed_block;
117 s->zstream.avail_in = bytes; 117 s->zstream.avail_in = bytes;
118 s->zstream.next_out = s->uncompressed_block; 118 s->zstream.next_out = s->uncompressed_block;
@@ -123,13 +123,13 @@ static inline int cloop_read_block(BDRVCloopState *s,int block_num) @@ -123,13 +123,13 @@ static inline int cloop_read_block(BDRVCloopState *s,int block_num)
123 ret = inflate(&s->zstream, Z_FINISH); 123 ret = inflate(&s->zstream, Z_FINISH);
124 if(ret != Z_STREAM_END || s->zstream.total_out != s->block_size) 124 if(ret != Z_STREAM_END || s->zstream.total_out != s->block_size)
125 return -1; 125 return -1;
126 - 126 +
127 s->current_block = block_num; 127 s->current_block = block_num;
128 } 128 }
129 return 0; 129 return 0;
130 } 130 }
131 131
132 -static int cloop_read(BlockDriverState *bs, int64_t sector_num, 132 +static int cloop_read(BlockDriverState *bs, int64_t sector_num,
133 uint8_t *buf, int nb_sectors) 133 uint8_t *buf, int nb_sectors)
134 { 134 {
135 BDRVCloopState *s = bs->opaque; 135 BDRVCloopState *s = bs->opaque;
block-cow.c
1 /* 1 /*
2 * Block driver for the COW format 2 * Block driver for the COW format
3 - * 3 + *
4 * Copyright (c) 2004 Fabrice Bellard 4 * Copyright (c) 2004 Fabrice Bellard
5 - * 5 + *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy 6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal 7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights 8 * in the Software without restriction, including without limitation the rights
@@ -56,7 +56,7 @@ static int cow_probe(const uint8_t *buf, int buf_size, const char *filename) @@ -56,7 +56,7 @@ static int cow_probe(const uint8_t *buf, int buf_size, const char *filename)
56 56
57 if (buf_size >= sizeof(struct cow_header_v2) && 57 if (buf_size >= sizeof(struct cow_header_v2) &&
58 be32_to_cpu(cow_header->magic) == COW_MAGIC && 58 be32_to_cpu(cow_header->magic) == COW_MAGIC &&
59 - be32_to_cpu(cow_header->version) == COW_VERSION) 59 + be32_to_cpu(cow_header->version) == COW_VERSION)
60 return 100; 60 return 100;
61 else 61 else
62 return 0; 62 return 0;
@@ -85,18 +85,18 @@ static int cow_open(BlockDriverState *bs, const char *filename, int flags) @@ -85,18 +85,18 @@ static int cow_open(BlockDriverState *bs, const char *filename, int flags)
85 be32_to_cpu(cow_header.version) != COW_VERSION) { 85 be32_to_cpu(cow_header.version) != COW_VERSION) {
86 goto fail; 86 goto fail;
87 } 87 }
88 - 88 +
89 /* cow image found */ 89 /* cow image found */
90 size = be64_to_cpu(cow_header.size); 90 size = be64_to_cpu(cow_header.size);
91 bs->total_sectors = size / 512; 91 bs->total_sectors = size / 512;
92 92
93 - pstrcpy(bs->backing_file, sizeof(bs->backing_file), 93 + pstrcpy(bs->backing_file, sizeof(bs->backing_file),
94 cow_header.backing_file); 94 cow_header.backing_file);
95 - 95 +
96 /* mmap the bitmap */ 96 /* mmap the bitmap */
97 s->cow_bitmap_size = ((bs->total_sectors + 7) >> 3) + sizeof(cow_header); 97 s->cow_bitmap_size = ((bs->total_sectors + 7) >> 3) + sizeof(cow_header);
98 - s->cow_bitmap_addr = mmap(get_mmap_addr(s->cow_bitmap_size),  
99 - s->cow_bitmap_size, 98 + s->cow_bitmap_addr = mmap(get_mmap_addr(s->cow_bitmap_size),
  99 + s->cow_bitmap_size,
100 PROT_READ | PROT_WRITE, 100 PROT_READ | PROT_WRITE,
101 MAP_SHARED, s->fd, 0); 101 MAP_SHARED, s->fd, 0);
102 if (s->cow_bitmap_addr == MAP_FAILED) 102 if (s->cow_bitmap_addr == MAP_FAILED)
@@ -143,24 +143,24 @@ static inline int is_changed(uint8_t *bitmap, @@ -143,24 +143,24 @@ static inline int is_changed(uint8_t *bitmap,
143 return changed; 143 return changed;
144 } 144 }
145 145
146 -static int cow_is_allocated(BlockDriverState *bs, int64_t sector_num, 146 +static int cow_is_allocated(BlockDriverState *bs, int64_t sector_num,
147 int nb_sectors, int *pnum) 147 int nb_sectors, int *pnum)
148 { 148 {
149 BDRVCowState *s = bs->opaque; 149 BDRVCowState *s = bs->opaque;
150 return is_changed(s->cow_bitmap, sector_num, nb_sectors, pnum); 150 return is_changed(s->cow_bitmap, sector_num, nb_sectors, pnum);
151 } 151 }
152 152
153 -static int cow_read(BlockDriverState *bs, int64_t sector_num, 153 +static int cow_read(BlockDriverState *bs, int64_t sector_num,
154 uint8_t *buf, int nb_sectors) 154 uint8_t *buf, int nb_sectors)
155 { 155 {
156 BDRVCowState *s = bs->opaque; 156 BDRVCowState *s = bs->opaque;
157 int ret, n; 157 int ret, n;
158 - 158 +
159 while (nb_sectors > 0) { 159 while (nb_sectors > 0) {
160 if (is_changed(s->cow_bitmap, sector_num, nb_sectors, &n)) { 160 if (is_changed(s->cow_bitmap, sector_num, nb_sectors, &n)) {
161 lseek(s->fd, s->cow_sectors_offset + sector_num * 512, SEEK_SET); 161 lseek(s->fd, s->cow_sectors_offset + sector_num * 512, SEEK_SET);
162 ret = read(s->fd, buf, n * 512); 162 ret = read(s->fd, buf, n * 512);
163 - if (ret != n * 512) 163 + if (ret != n * 512)
164 return -1; 164 return -1;
165 } else { 165 } else {
166 if (bs->backing_hd) { 166 if (bs->backing_hd) {
@@ -179,15 +179,15 @@ static int cow_read(BlockDriverState *bs, int64_t sector_num, @@ -179,15 +179,15 @@ static int cow_read(BlockDriverState *bs, int64_t sector_num,
179 return 0; 179 return 0;
180 } 180 }
181 181
182 -static int cow_write(BlockDriverState *bs, int64_t sector_num, 182 +static int cow_write(BlockDriverState *bs, int64_t sector_num,
183 const uint8_t *buf, int nb_sectors) 183 const uint8_t *buf, int nb_sectors)
184 { 184 {
185 BDRVCowState *s = bs->opaque; 185 BDRVCowState *s = bs->opaque;
186 int ret, i; 186 int ret, i;
187 - 187 +
188 lseek(s->fd, s->cow_sectors_offset + sector_num * 512, SEEK_SET); 188 lseek(s->fd, s->cow_sectors_offset + sector_num * 512, SEEK_SET);
189 ret = write(s->fd, buf, nb_sectors * 512); 189 ret = write(s->fd, buf, nb_sectors * 512);
190 - if (ret != nb_sectors * 512) 190 + if (ret != nb_sectors * 512)
191 return -1; 191 return -1;
192 for (i = 0; i < nb_sectors; i++) 192 for (i = 0; i < nb_sectors; i++)
193 cow_set_bit(s->cow_bitmap, sector_num + i); 193 cow_set_bit(s->cow_bitmap, sector_num + i);
@@ -211,7 +211,7 @@ static int cow_create(const char *filename, int64_t image_sectors, @@ -211,7 +211,7 @@ static int cow_create(const char *filename, int64_t image_sectors,
211 if (flags) 211 if (flags)
212 return -ENOTSUP; 212 return -ENOTSUP;
213 213
214 - cow_fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 214 + cow_fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY,
215 0644); 215 0644);
216 if (cow_fd < 0) 216 if (cow_fd < 0)
217 return -1; 217 return -1;
block-dmg.c
1 /* 1 /*
2 * QEMU Block driver for DMG images 2 * QEMU Block driver for DMG images
3 - * 3 + *
4 * Copyright (c) 2004 Johannes E. Schindelin 4 * Copyright (c) 2004 Johannes E. Schindelin
5 - * 5 + *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy 6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal 7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights 8 * in the Software without restriction, including without limitation the rights
@@ -28,7 +28,7 @@ @@ -28,7 +28,7 @@
28 28
29 typedef struct BDRVDMGState { 29 typedef struct BDRVDMGState {
30 int fd; 30 int fd;
31 - 31 +
32 /* each chunk contains a certain number of sectors, 32 /* each chunk contains a certain number of sectors,
33 * offsets[i] is the offset in the .dmg file, 33 * offsets[i] is the offset in the .dmg file,
34 * lengths[i] is the length of the compressed chunk, 34 * lengths[i] is the length of the compressed chunk,
@@ -86,7 +86,7 @@ static int dmg_open(BlockDriverState *bs, const char *filename, int flags) @@ -86,7 +86,7 @@ static int dmg_open(BlockDriverState *bs, const char *filename, int flags)
86 bs->read_only = 1; 86 bs->read_only = 1;
87 s->n_chunks = 0; 87 s->n_chunks = 0;
88 s->offsets = s->lengths = s->sectors = s->sectorcounts = 0; 88 s->offsets = s->lengths = s->sectors = s->sectorcounts = 0;
89 - 89 +
90 /* read offset of info blocks */ 90 /* read offset of info blocks */
91 if(lseek(s->fd,-0x1d8,SEEK_END)<0) { 91 if(lseek(s->fd,-0x1d8,SEEK_END)<0) {
92 dmg_close: 92 dmg_close:
@@ -167,7 +167,7 @@ dmg_close: @@ -167,7 +167,7 @@ dmg_close:
167 goto dmg_close; 167 goto dmg_close;
168 168
169 s->current_chunk = s->n_chunks; 169 s->current_chunk = s->n_chunks;
170 - 170 +
171 return 0; 171 return 0;
172 } 172 }
173 173
@@ -227,7 +227,7 @@ static inline int dmg_read_chunk(BDRVDMGState *s,int sector_num) @@ -227,7 +227,7 @@ static inline int dmg_read_chunk(BDRVDMGState *s,int sector_num)
227 227
228 if (ret != s->lengths[chunk]) 228 if (ret != s->lengths[chunk])
229 return -1; 229 return -1;
230 - 230 +
231 s->zstream.next_in = s->compressed_chunk; 231 s->zstream.next_in = s->compressed_chunk;
232 s->zstream.avail_in = s->lengths[chunk]; 232 s->zstream.avail_in = s->lengths[chunk];
233 s->zstream.next_out = s->uncompressed_chunk; 233 s->zstream.next_out = s->uncompressed_chunk;
@@ -253,7 +253,7 @@ static inline int dmg_read_chunk(BDRVDMGState *s,int sector_num) @@ -253,7 +253,7 @@ static inline int dmg_read_chunk(BDRVDMGState *s,int sector_num)
253 return 0; 253 return 0;
254 } 254 }
255 255
256 -static int dmg_read(BlockDriverState *bs, int64_t sector_num, 256 +static int dmg_read(BlockDriverState *bs, int64_t sector_num,
257 uint8_t *buf, int nb_sectors) 257 uint8_t *buf, int nb_sectors)
258 { 258 {
259 BDRVDMGState *s = bs->opaque; 259 BDRVDMGState *s = bs->opaque;
block-qcow.c
1 /* 1 /*
2 * Block driver for the QCOW format 2 * Block driver for the QCOW format
3 - * 3 + *
4 * Copyright (c) 2004-2006 Fabrice Bellard 4 * Copyright (c) 2004-2006 Fabrice Bellard
5 - * 5 + *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy 6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal 7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights 8 * in the Software without restriction, including without limitation the rights
@@ -80,10 +80,10 @@ static int decompress_cluster(BDRVQcowState *s, uint64_t cluster_offset); @@ -80,10 +80,10 @@ static int decompress_cluster(BDRVQcowState *s, uint64_t cluster_offset);
80 static int qcow_probe(const uint8_t *buf, int buf_size, const char *filename) 80 static int qcow_probe(const uint8_t *buf, int buf_size, const char *filename)
81 { 81 {
82 const QCowHeader *cow_header = (const void *)buf; 82 const QCowHeader *cow_header = (const void *)buf;
83 - 83 +
84 if (buf_size >= sizeof(QCowHeader) && 84 if (buf_size >= sizeof(QCowHeader) &&
85 be32_to_cpu(cow_header->magic) == QCOW_MAGIC && 85 be32_to_cpu(cow_header->magic) == QCOW_MAGIC &&
86 - be32_to_cpu(cow_header->version) == QCOW_VERSION) 86 + be32_to_cpu(cow_header->version) == QCOW_VERSION)
87 return 100; 87 return 100;
88 else 88 else
89 return 0; 89 return 0;
@@ -108,7 +108,7 @@ static int qcow_open(BlockDriverState *bs, const char *filename, int flags) @@ -108,7 +108,7 @@ static int qcow_open(BlockDriverState *bs, const char *filename, int flags)
108 be64_to_cpus(&header.size); 108 be64_to_cpus(&header.size);
109 be32_to_cpus(&header.crypt_method); 109 be32_to_cpus(&header.crypt_method);
110 be64_to_cpus(&header.l1_table_offset); 110 be64_to_cpus(&header.l1_table_offset);
111 - 111 +
112 if (header.magic != QCOW_MAGIC || header.version != QCOW_VERSION) 112 if (header.magic != QCOW_MAGIC || header.version != QCOW_VERSION)
113 goto fail; 113 goto fail;
114 if (header.size <= 1 || header.cluster_bits < 9) 114 if (header.size <= 1 || header.cluster_bits < 9)
@@ -134,7 +134,7 @@ static int qcow_open(BlockDriverState *bs, const char *filename, int flags) @@ -134,7 +134,7 @@ static int qcow_open(BlockDriverState *bs, const char *filename, int flags)
134 s->l1_table = qemu_malloc(s->l1_size * sizeof(uint64_t)); 134 s->l1_table = qemu_malloc(s->l1_size * sizeof(uint64_t));
135 if (!s->l1_table) 135 if (!s->l1_table)
136 goto fail; 136 goto fail;
137 - if (bdrv_pread(s->hd, s->l1_table_offset, s->l1_table, s->l1_size * sizeof(uint64_t)) != 137 + if (bdrv_pread(s->hd, s->l1_table_offset, s->l1_table, s->l1_size * sizeof(uint64_t)) !=
138 s->l1_size * sizeof(uint64_t)) 138 s->l1_size * sizeof(uint64_t))
139 goto fail; 139 goto fail;
140 for(i = 0;i < s->l1_size; i++) { 140 for(i = 0;i < s->l1_size; i++) {
@@ -151,7 +151,7 @@ static int qcow_open(BlockDriverState *bs, const char *filename, int flags) @@ -151,7 +151,7 @@ static int qcow_open(BlockDriverState *bs, const char *filename, int flags)
151 if (!s->cluster_data) 151 if (!s->cluster_data)
152 goto fail; 152 goto fail;
153 s->cluster_cache_offset = -1; 153 s->cluster_cache_offset = -1;
154 - 154 +
155 /* read the backing file name */ 155 /* read the backing file name */
156 if (header.backing_file_offset != 0) { 156 if (header.backing_file_offset != 0) {
157 len = header.backing_file_size; 157 len = header.backing_file_size;
@@ -177,7 +177,7 @@ static int qcow_set_key(BlockDriverState *bs, const char *key) @@ -177,7 +177,7 @@ static int qcow_set_key(BlockDriverState *bs, const char *key)
177 BDRVQcowState *s = bs->opaque; 177 BDRVQcowState *s = bs->opaque;
178 uint8_t keybuf[16]; 178 uint8_t keybuf[16];
179 int len, i; 179 int len, i;
180 - 180 +
181 memset(keybuf, 0, 16); 181 memset(keybuf, 0, 16);
182 len = strlen(key); 182 len = strlen(key);
183 if (len > 16) 183 if (len > 16)
@@ -231,7 +231,7 @@ static void encrypt_sectors(BDRVQcowState *s, int64_t sector_num, @@ -231,7 +231,7 @@ static void encrypt_sectors(BDRVQcowState *s, int64_t sector_num,
231 for(i = 0; i < nb_sectors; i++) { 231 for(i = 0; i < nb_sectors; i++) {
232 ivec.ll[0] = cpu_to_le64(sector_num); 232 ivec.ll[0] = cpu_to_le64(sector_num);
233 ivec.ll[1] = 0; 233 ivec.ll[1] = 0;
234 - AES_cbc_encrypt(in_buf, out_buf, 512, key, 234 + AES_cbc_encrypt(in_buf, out_buf, 512, key,
235 ivec.b, enc); 235 ivec.b, enc);
236 sector_num++; 236 sector_num++;
237 in_buf += 512; 237 in_buf += 512;
@@ -248,7 +248,7 @@ static void encrypt_sectors(BDRVQcowState *s, int64_t sector_num, @@ -248,7 +248,7 @@ static void encrypt_sectors(BDRVQcowState *s, int64_t sector_num,
248 * 248 *
249 * 2 to allocate a compressed cluster of size 249 * 2 to allocate a compressed cluster of size
250 * 'compressed_size'. 'compressed_size' must be > 0 and < 250 * 'compressed_size'. 'compressed_size' must be > 0 and <
251 - * cluster_size 251 + * cluster_size
252 * 252 *
253 * return 0 if not allocated. 253 * return 0 if not allocated.
254 */ 254 */
@@ -262,7 +262,7 @@ static uint64_t get_cluster_offset(BlockDriverState *bs, @@ -262,7 +262,7 @@ static uint64_t get_cluster_offset(BlockDriverState *bs,
262 uint64_t l2_offset, *l2_table, cluster_offset, tmp; 262 uint64_t l2_offset, *l2_table, cluster_offset, tmp;
263 uint32_t min_count; 263 uint32_t min_count;
264 int new_l2_table; 264 int new_l2_table;
265 - 265 +
266 l1_index = offset >> (s->l2_bits + s->cluster_bits); 266 l1_index = offset >> (s->l2_bits + s->cluster_bits);
267 l2_offset = s->l1_table[l1_index]; 267 l2_offset = s->l1_table[l1_index];
268 new_l2_table = 0; 268 new_l2_table = 0;
@@ -276,7 +276,7 @@ static uint64_t get_cluster_offset(BlockDriverState *bs, @@ -276,7 +276,7 @@ static uint64_t get_cluster_offset(BlockDriverState *bs,
276 /* update the L1 entry */ 276 /* update the L1 entry */
277 s->l1_table[l1_index] = l2_offset; 277 s->l1_table[l1_index] = l2_offset;
278 tmp = cpu_to_be64(l2_offset); 278 tmp = cpu_to_be64(l2_offset);
279 - if (bdrv_pwrite(s->hd, s->l1_table_offset + l1_index * sizeof(tmp), 279 + if (bdrv_pwrite(s->hd, s->l1_table_offset + l1_index * sizeof(tmp),
280 &tmp, sizeof(tmp)) != sizeof(tmp)) 280 &tmp, sizeof(tmp)) != sizeof(tmp))
281 return 0; 281 return 0;
282 new_l2_table = 1; 282 new_l2_table = 1;
@@ -309,7 +309,7 @@ static uint64_t get_cluster_offset(BlockDriverState *bs, @@ -309,7 +309,7 @@ static uint64_t get_cluster_offset(BlockDriverState *bs,
309 s->l2_size * sizeof(uint64_t)) 309 s->l2_size * sizeof(uint64_t))
310 return 0; 310 return 0;
311 } else { 311 } else {
312 - if (bdrv_pread(s->hd, l2_offset, l2_table, s->l2_size * sizeof(uint64_t)) != 312 + if (bdrv_pread(s->hd, l2_offset, l2_table, s->l2_size * sizeof(uint64_t)) !=
313 s->l2_size * sizeof(uint64_t)) 313 s->l2_size * sizeof(uint64_t))
314 return 0; 314 return 0;
315 } 315 }
@@ -318,7 +318,7 @@ static uint64_t get_cluster_offset(BlockDriverState *bs, @@ -318,7 +318,7 @@ static uint64_t get_cluster_offset(BlockDriverState *bs,
318 found: 318 found:
319 l2_index = (offset >> s->cluster_bits) & (s->l2_size - 1); 319 l2_index = (offset >> s->cluster_bits) & (s->l2_size - 1);
320 cluster_offset = be64_to_cpu(l2_table[l2_index]); 320 cluster_offset = be64_to_cpu(l2_table[l2_index]);
321 - if (!cluster_offset || 321 + if (!cluster_offset ||
322 ((cluster_offset & QCOW_OFLAG_COMPRESSED) && allocate == 1)) { 322 ((cluster_offset & QCOW_OFLAG_COMPRESSED) && allocate == 1)) {
323 if (!allocate) 323 if (!allocate)
324 return 0; 324 return 0;
@@ -331,54 +331,54 @@ static uint64_t get_cluster_offset(BlockDriverState *bs, @@ -331,54 +331,54 @@ static uint64_t get_cluster_offset(BlockDriverState *bs,
331 if (decompress_cluster(s, cluster_offset) < 0) 331 if (decompress_cluster(s, cluster_offset) < 0)
332 return 0; 332 return 0;
333 cluster_offset = bdrv_getlength(s->hd); 333 cluster_offset = bdrv_getlength(s->hd);
334 - cluster_offset = (cluster_offset + s->cluster_size - 1) & 334 + cluster_offset = (cluster_offset + s->cluster_size - 1) &
335 ~(s->cluster_size - 1); 335 ~(s->cluster_size - 1);
336 /* write the cluster content */ 336 /* write the cluster content */
337 - if (bdrv_pwrite(s->hd, cluster_offset, s->cluster_cache, s->cluster_size) != 337 + if (bdrv_pwrite(s->hd, cluster_offset, s->cluster_cache, s->cluster_size) !=
338 s->cluster_size) 338 s->cluster_size)
339 return -1; 339 return -1;
340 } else { 340 } else {
341 cluster_offset = bdrv_getlength(s->hd); 341 cluster_offset = bdrv_getlength(s->hd);
342 if (allocate == 1) { 342 if (allocate == 1) {
343 /* round to cluster size */ 343 /* round to cluster size */
344 - cluster_offset = (cluster_offset + s->cluster_size - 1) & 344 + cluster_offset = (cluster_offset + s->cluster_size - 1) &
345 ~(s->cluster_size - 1); 345 ~(s->cluster_size - 1);
346 bdrv_truncate(s->hd, cluster_offset + s->cluster_size); 346 bdrv_truncate(s->hd, cluster_offset + s->cluster_size);
347 /* if encrypted, we must initialize the cluster 347 /* if encrypted, we must initialize the cluster
348 content which won't be written */ 348 content which won't be written */
349 - if (s->crypt_method && 349 + if (s->crypt_method &&
350 (n_end - n_start) < s->cluster_sectors) { 350 (n_end - n_start) < s->cluster_sectors) {
351 uint64_t start_sect; 351 uint64_t start_sect;
352 start_sect = (offset & ~(s->cluster_size - 1)) >> 9; 352 start_sect = (offset & ~(s->cluster_size - 1)) >> 9;
353 memset(s->cluster_data + 512, 0x00, 512); 353 memset(s->cluster_data + 512, 0x00, 512);
354 for(i = 0; i < s->cluster_sectors; i++) { 354 for(i = 0; i < s->cluster_sectors; i++) {
355 if (i < n_start || i >= n_end) { 355 if (i < n_start || i >= n_end) {
356 - encrypt_sectors(s, start_sect + i,  
357 - s->cluster_data, 356 + encrypt_sectors(s, start_sect + i,
  357 + s->cluster_data,
358 s->cluster_data + 512, 1, 1, 358 s->cluster_data + 512, 1, 1,
359 &s->aes_encrypt_key); 359 &s->aes_encrypt_key);
360 - if (bdrv_pwrite(s->hd, cluster_offset + i * 512, 360 + if (bdrv_pwrite(s->hd, cluster_offset + i * 512,
361 s->cluster_data, 512) != 512) 361 s->cluster_data, 512) != 512)
362 return -1; 362 return -1;
363 } 363 }
364 } 364 }
365 } 365 }
366 } else { 366 } else {
367 - cluster_offset |= QCOW_OFLAG_COMPRESSED | 367 + cluster_offset |= QCOW_OFLAG_COMPRESSED |
368 (uint64_t)compressed_size << (63 - s->cluster_bits); 368 (uint64_t)compressed_size << (63 - s->cluster_bits);
369 } 369 }
370 } 370 }
371 /* update L2 table */ 371 /* update L2 table */
372 tmp = cpu_to_be64(cluster_offset); 372 tmp = cpu_to_be64(cluster_offset);
373 l2_table[l2_index] = tmp; 373 l2_table[l2_index] = tmp;
374 - if (bdrv_pwrite(s->hd, 374 + if (bdrv_pwrite(s->hd,
375 l2_offset + l2_index * sizeof(tmp), &tmp, sizeof(tmp)) != sizeof(tmp)) 375 l2_offset + l2_index * sizeof(tmp), &tmp, sizeof(tmp)) != sizeof(tmp))
376 return 0; 376 return 0;
377 } 377 }
378 return cluster_offset; 378 return cluster_offset;
379 } 379 }
380 380
381 -static int qcow_is_allocated(BlockDriverState *bs, int64_t sector_num, 381 +static int qcow_is_allocated(BlockDriverState *bs, int64_t sector_num,
382 int nb_sectors, int *pnum) 382 int nb_sectors, int *pnum)
383 { 383 {
384 BDRVQcowState *s = bs->opaque; 384 BDRVQcowState *s = bs->opaque;
@@ -420,7 +420,7 @@ static int decompress_buffer(uint8_t *out_buf, int out_buf_size, @@ -420,7 +420,7 @@ static int decompress_buffer(uint8_t *out_buf, int out_buf_size,
420 inflateEnd(strm); 420 inflateEnd(strm);
421 return 0; 421 return 0;
422 } 422 }
423 - 423 +
424 static int decompress_cluster(BDRVQcowState *s, uint64_t cluster_offset) 424 static int decompress_cluster(BDRVQcowState *s, uint64_t cluster_offset)
425 { 425 {
426 int ret, csize; 426 int ret, csize;
@@ -431,7 +431,7 @@ static int decompress_cluster(BDRVQcowState *s, uint64_t cluster_offset) @@ -431,7 +431,7 @@ static int decompress_cluster(BDRVQcowState *s, uint64_t cluster_offset)
431 csize = cluster_offset >> (63 - s->cluster_bits); 431 csize = cluster_offset >> (63 - s->cluster_bits);
432 csize &= (s->cluster_size - 1); 432 csize &= (s->cluster_size - 1);
433 ret = bdrv_pread(s->hd, coffset, s->cluster_data, csize); 433 ret = bdrv_pread(s->hd, coffset, s->cluster_data, csize);
434 - if (ret != csize) 434 + if (ret != csize)
435 return -1; 435 return -1;
436 if (decompress_buffer(s->cluster_cache, s->cluster_size, 436 if (decompress_buffer(s->cluster_cache, s->cluster_size,
437 s->cluster_data, csize) < 0) { 437 s->cluster_data, csize) < 0) {
@@ -444,13 +444,13 @@ static int decompress_cluster(BDRVQcowState *s, uint64_t cluster_offset) @@ -444,13 +444,13 @@ static int decompress_cluster(BDRVQcowState *s, uint64_t cluster_offset)
444 444
445 #if 0 445 #if 0
446 446
447 -static int qcow_read(BlockDriverState *bs, int64_t sector_num, 447 +static int qcow_read(BlockDriverState *bs, int64_t sector_num,
448 uint8_t *buf, int nb_sectors) 448 uint8_t *buf, int nb_sectors)
449 { 449 {
450 BDRVQcowState *s = bs->opaque; 450 BDRVQcowState *s = bs->opaque;
451 int ret, index_in_cluster, n; 451 int ret, index_in_cluster, n;
452 uint64_t cluster_offset; 452 uint64_t cluster_offset;
453 - 453 +
454 while (nb_sectors > 0) { 454 while (nb_sectors > 0) {
455 cluster_offset = get_cluster_offset(bs, sector_num << 9, 0, 0, 0, 0); 455 cluster_offset = get_cluster_offset(bs, sector_num << 9, 0, 0, 0, 0);
456 index_in_cluster = sector_num & (s->cluster_sectors - 1); 456 index_in_cluster = sector_num & (s->cluster_sectors - 1);
@@ -472,10 +472,10 @@ static int qcow_read(BlockDriverState *bs, int64_t sector_num, @@ -472,10 +472,10 @@ static int qcow_read(BlockDriverState *bs, int64_t sector_num,
472 memcpy(buf, s->cluster_cache + index_in_cluster * 512, 512 * n); 472 memcpy(buf, s->cluster_cache + index_in_cluster * 512, 512 * n);
473 } else { 473 } else {
474 ret = bdrv_pread(s->hd, cluster_offset + index_in_cluster * 512, buf, n * 512); 474 ret = bdrv_pread(s->hd, cluster_offset + index_in_cluster * 512, buf, n * 512);
475 - if (ret != n * 512) 475 + if (ret != n * 512)
476 return -1; 476 return -1;
477 if (s->crypt_method) { 477 if (s->crypt_method) {
478 - encrypt_sectors(s, sector_num, buf, buf, n, 0, 478 + encrypt_sectors(s, sector_num, buf, buf, n, 0,
479 &s->aes_decrypt_key); 479 &s->aes_decrypt_key);
480 } 480 }
481 } 481 }
@@ -487,32 +487,32 @@ static int qcow_read(BlockDriverState *bs, int64_t sector_num, @@ -487,32 +487,32 @@ static int qcow_read(BlockDriverState *bs, int64_t sector_num,
487 } 487 }
488 #endif 488 #endif
489 489
490 -static int qcow_write(BlockDriverState *bs, int64_t sector_num, 490 +static int qcow_write(BlockDriverState *bs, int64_t sector_num,
491 const uint8_t *buf, int nb_sectors) 491 const uint8_t *buf, int nb_sectors)
492 { 492 {
493 BDRVQcowState *s = bs->opaque; 493 BDRVQcowState *s = bs->opaque;
494 int ret, index_in_cluster, n; 494 int ret, index_in_cluster, n;
495 uint64_t cluster_offset; 495 uint64_t cluster_offset;
496 - 496 +
497 while (nb_sectors > 0) { 497 while (nb_sectors > 0) {
498 index_in_cluster = sector_num & (s->cluster_sectors - 1); 498 index_in_cluster = sector_num & (s->cluster_sectors - 1);
499 n = s->cluster_sectors - index_in_cluster; 499 n = s->cluster_sectors - index_in_cluster;
500 if (n > nb_sectors) 500 if (n > nb_sectors)
501 n = nb_sectors; 501 n = nb_sectors;
502 - cluster_offset = get_cluster_offset(bs, sector_num << 9, 1, 0,  
503 - index_in_cluster, 502 + cluster_offset = get_cluster_offset(bs, sector_num << 9, 1, 0,
  503 + index_in_cluster,
504 index_in_cluster + n); 504 index_in_cluster + n);
505 if (!cluster_offset) 505 if (!cluster_offset)
506 return -1; 506 return -1;
507 if (s->crypt_method) { 507 if (s->crypt_method) {
508 encrypt_sectors(s, sector_num, s->cluster_data, buf, n, 1, 508 encrypt_sectors(s, sector_num, s->cluster_data, buf, n, 1,
509 &s->aes_encrypt_key); 509 &s->aes_encrypt_key);
510 - ret = bdrv_pwrite(s->hd, cluster_offset + index_in_cluster * 512, 510 + ret = bdrv_pwrite(s->hd, cluster_offset + index_in_cluster * 512,
511 s->cluster_data, n * 512); 511 s->cluster_data, n * 512);
512 } else { 512 } else {
513 ret = bdrv_pwrite(s->hd, cluster_offset + index_in_cluster * 512, buf, n * 512); 513 ret = bdrv_pwrite(s->hd, cluster_offset + index_in_cluster * 512, buf, n * 512);
514 } 514 }
515 - if (ret != n * 512) 515 + if (ret != n * 512)
516 return -1; 516 return -1;
517 nb_sectors -= n; 517 nb_sectors -= n;
518 sector_num += n; 518 sector_num += n;
@@ -529,7 +529,7 @@ typedef struct QCowAIOCB { @@ -529,7 +529,7 @@ typedef struct QCowAIOCB {
529 int nb_sectors; 529 int nb_sectors;
530 int n; 530 int n;
531 uint64_t cluster_offset; 531 uint64_t cluster_offset;
532 - uint8_t *cluster_data; 532 + uint8_t *cluster_data;
533 BlockDriverAIOCB *hd_aiocb; 533 BlockDriverAIOCB *hd_aiocb;
534 } QCowAIOCB; 534 } QCowAIOCB;
535 535
@@ -556,8 +556,8 @@ static void qcow_aio_read_cb(void *opaque, int ret) @@ -556,8 +556,8 @@ static void qcow_aio_read_cb(void *opaque, int ret)
556 /* nothing to do */ 556 /* nothing to do */
557 } else { 557 } else {
558 if (s->crypt_method) { 558 if (s->crypt_method) {
559 - encrypt_sectors(s, acb->sector_num, acb->buf, acb->buf,  
560 - acb->n, 0, 559 + encrypt_sectors(s, acb->sector_num, acb->buf, acb->buf,
  560 + acb->n, 0,
561 &s->aes_decrypt_key); 561 &s->aes_decrypt_key);
562 } 562 }
563 } 563 }
@@ -572,9 +572,9 @@ static void qcow_aio_read_cb(void *opaque, int ret) @@ -572,9 +572,9 @@ static void qcow_aio_read_cb(void *opaque, int ret)
572 qemu_aio_release(acb); 572 qemu_aio_release(acb);
573 return; 573 return;
574 } 574 }
575 - 575 +
576 /* prepare next AIO request */ 576 /* prepare next AIO request */
577 - acb->cluster_offset = get_cluster_offset(bs, acb->sector_num << 9, 577 + acb->cluster_offset = get_cluster_offset(bs, acb->sector_num << 9,
578 0, 0, 0, 0); 578 0, 0, 0, 0);
579 index_in_cluster = acb->sector_num & (s->cluster_sectors - 1); 579 index_in_cluster = acb->sector_num & (s->cluster_sectors - 1);
580 acb->n = s->cluster_sectors - index_in_cluster; 580 acb->n = s->cluster_sectors - index_in_cluster;
@@ -597,7 +597,7 @@ static void qcow_aio_read_cb(void *opaque, int ret) @@ -597,7 +597,7 @@ static void qcow_aio_read_cb(void *opaque, int ret)
597 /* add AIO support for compressed blocks ? */ 597 /* add AIO support for compressed blocks ? */
598 if (decompress_cluster(s, acb->cluster_offset) < 0) 598 if (decompress_cluster(s, acb->cluster_offset) < 0)
599 goto fail; 599 goto fail;
600 - memcpy(acb->buf, 600 + memcpy(acb->buf,
601 s->cluster_cache + index_in_cluster * 512, 512 * acb->n); 601 s->cluster_cache + index_in_cluster * 512, 512 * acb->n);
602 goto redo; 602 goto redo;
603 } else { 603 } else {
@@ -606,7 +606,7 @@ static void qcow_aio_read_cb(void *opaque, int ret) @@ -606,7 +606,7 @@ static void qcow_aio_read_cb(void *opaque, int ret)
606 goto fail; 606 goto fail;
607 } 607 }
608 acb->hd_aiocb = bdrv_aio_read(s->hd, 608 acb->hd_aiocb = bdrv_aio_read(s->hd,
609 - (acb->cluster_offset >> 9) + index_in_cluster, 609 + (acb->cluster_offset >> 9) + index_in_cluster,
610 acb->buf, acb->n, qcow_aio_read_cb, acb); 610 acb->buf, acb->n, qcow_aio_read_cb, acb);
611 if (acb->hd_aiocb == NULL) 611 if (acb->hd_aiocb == NULL)
612 goto fail; 612 goto fail;
@@ -627,7 +627,7 @@ static BlockDriverAIOCB *qcow_aio_read(BlockDriverState *bs, @@ -627,7 +627,7 @@ static BlockDriverAIOCB *qcow_aio_read(BlockDriverState *bs,
627 acb->buf = buf; 627 acb->buf = buf;
628 acb->nb_sectors = nb_sectors; 628 acb->nb_sectors = nb_sectors;
629 acb->n = 0; 629 acb->n = 0;
630 - acb->cluster_offset = 0; 630 + acb->cluster_offset = 0;
631 631
632 qcow_aio_read_cb(acb, 0); 632 qcow_aio_read_cb(acb, 0);
633 return &acb->common; 633 return &acb->common;
@@ -661,13 +661,13 @@ static void qcow_aio_write_cb(void *opaque, int ret) @@ -661,13 +661,13 @@ static void qcow_aio_write_cb(void *opaque, int ret)
661 qemu_aio_release(acb); 661 qemu_aio_release(acb);
662 return; 662 return;
663 } 663 }
664 - 664 +
665 index_in_cluster = acb->sector_num & (s->cluster_sectors - 1); 665 index_in_cluster = acb->sector_num & (s->cluster_sectors - 1);
666 acb->n = s->cluster_sectors - index_in_cluster; 666 acb->n = s->cluster_sectors - index_in_cluster;
667 if (acb->n > acb->nb_sectors) 667 if (acb->n > acb->nb_sectors)
668 acb->n = acb->nb_sectors; 668 acb->n = acb->nb_sectors;
669 - cluster_offset = get_cluster_offset(bs, acb->sector_num << 9, 1, 0,  
670 - index_in_cluster, 669 + cluster_offset = get_cluster_offset(bs, acb->sector_num << 9, 1, 0,
  670 + index_in_cluster,
671 index_in_cluster + acb->n); 671 index_in_cluster + acb->n);
672 if (!cluster_offset || (cluster_offset & 511) != 0) { 672 if (!cluster_offset || (cluster_offset & 511) != 0) {
673 ret = -EIO; 673 ret = -EIO;
@@ -681,15 +681,15 @@ static void qcow_aio_write_cb(void *opaque, int ret) @@ -681,15 +681,15 @@ static void qcow_aio_write_cb(void *opaque, int ret)
681 goto fail; 681 goto fail;
682 } 682 }
683 } 683 }
684 - encrypt_sectors(s, acb->sector_num, acb->cluster_data, acb->buf, 684 + encrypt_sectors(s, acb->sector_num, acb->cluster_data, acb->buf,
685 acb->n, 1, &s->aes_encrypt_key); 685 acb->n, 1, &s->aes_encrypt_key);
686 src_buf = acb->cluster_data; 686 src_buf = acb->cluster_data;
687 } else { 687 } else {
688 src_buf = acb->buf; 688 src_buf = acb->buf;
689 } 689 }
690 acb->hd_aiocb = bdrv_aio_write(s->hd, 690 acb->hd_aiocb = bdrv_aio_write(s->hd,
691 - (cluster_offset >> 9) + index_in_cluster,  
692 - src_buf, acb->n, 691 + (cluster_offset >> 9) + index_in_cluster,
  692 + src_buf, acb->n,
693 qcow_aio_write_cb, acb); 693 qcow_aio_write_cb, acb);
694 if (acb->hd_aiocb == NULL) 694 if (acb->hd_aiocb == NULL)
695 goto fail; 695 goto fail;
@@ -701,7 +701,7 @@ static BlockDriverAIOCB *qcow_aio_write(BlockDriverState *bs, @@ -701,7 +701,7 @@ static BlockDriverAIOCB *qcow_aio_write(BlockDriverState *bs,
701 { 701 {
702 BDRVQcowState *s = bs->opaque; 702 BDRVQcowState *s = bs->opaque;
703 QCowAIOCB *acb; 703 QCowAIOCB *acb;
704 - 704 +
705 s->cluster_cache_offset = -1; /* disable compressed cache */ 705 s->cluster_cache_offset = -1; /* disable compressed cache */
706 706
707 acb = qemu_aio_get(bs, cb, opaque); 707 acb = qemu_aio_get(bs, cb, opaque);
@@ -712,7 +712,7 @@ static BlockDriverAIOCB *qcow_aio_write(BlockDriverState *bs, @@ -712,7 +712,7 @@ static BlockDriverAIOCB *qcow_aio_write(BlockDriverState *bs,
712 acb->buf = (uint8_t *)buf; 712 acb->buf = (uint8_t *)buf;
713 acb->nb_sectors = nb_sectors; 713 acb->nb_sectors = nb_sectors;
714 acb->n = 0; 714 acb->n = 0;
715 - 715 +
716 qcow_aio_write_cb(acb, 0); 716 qcow_aio_write_cb(acb, 0);
717 return &acb->common; 717 return &acb->common;
718 } 718 }
@@ -774,7 +774,7 @@ static int qcow_create(const char *filename, int64_t total_size, @@ -774,7 +774,7 @@ static int qcow_create(const char *filename, int64_t total_size,
774 } else { 774 } else {
775 header.crypt_method = cpu_to_be32(QCOW_CRYPT_NONE); 775 header.crypt_method = cpu_to_be32(QCOW_CRYPT_NONE);
776 } 776 }
777 - 777 +
778 /* write all the data */ 778 /* write all the data */
779 write(fd, &header, sizeof(header)); 779 write(fd, &header, sizeof(header));
780 if (backing_file) { 780 if (backing_file) {
@@ -811,7 +811,7 @@ static int qcow_make_empty(BlockDriverState *bs) @@ -811,7 +811,7 @@ static int qcow_make_empty(BlockDriverState *bs)
811 811
812 /* XXX: put compressed sectors first, then all the cluster aligned 812 /* XXX: put compressed sectors first, then all the cluster aligned
813 tables to avoid losing bytes in alignment */ 813 tables to avoid losing bytes in alignment */
814 -static int qcow_write_compressed(BlockDriverState *bs, int64_t sector_num, 814 +static int qcow_write_compressed(BlockDriverState *bs, int64_t sector_num,
815 const uint8_t *buf, int nb_sectors) 815 const uint8_t *buf, int nb_sectors)
816 { 816 {
817 BDRVQcowState *s = bs->opaque; 817 BDRVQcowState *s = bs->opaque;
@@ -830,7 +830,7 @@ static int qcow_write_compressed(BlockDriverState *bs, int64_t sector_num, @@ -830,7 +830,7 @@ static int qcow_write_compressed(BlockDriverState *bs, int64_t sector_num,
830 /* best compression, small window, no zlib header */ 830 /* best compression, small window, no zlib header */
831 memset(&strm, 0, sizeof(strm)); 831 memset(&strm, 0, sizeof(strm));
832 ret = deflateInit2(&strm, Z_DEFAULT_COMPRESSION, 832 ret = deflateInit2(&strm, Z_DEFAULT_COMPRESSION,
833 - Z_DEFLATED, -12, 833 + Z_DEFLATED, -12,
834 9, Z_DEFAULT_STRATEGY); 834 9, Z_DEFAULT_STRATEGY);
835 if (ret != 0) { 835 if (ret != 0) {
836 qemu_free(out_buf); 836 qemu_free(out_buf);
@@ -856,7 +856,7 @@ static int qcow_write_compressed(BlockDriverState *bs, int64_t sector_num, @@ -856,7 +856,7 @@ static int qcow_write_compressed(BlockDriverState *bs, int64_t sector_num,
856 /* could not compress: write normal cluster */ 856 /* could not compress: write normal cluster */
857 qcow_write(bs, sector_num, buf, s->cluster_sectors); 857 qcow_write(bs, sector_num, buf, s->cluster_sectors);
858 } else { 858 } else {
859 - cluster_offset = get_cluster_offset(bs, sector_num << 9, 2, 859 + cluster_offset = get_cluster_offset(bs, sector_num << 9, 2,
860 out_len, 0, 0); 860 out_len, 0, 0);
861 cluster_offset &= s->cluster_offset_mask; 861 cluster_offset &= s->cluster_offset_mask;
862 if (bdrv_pwrite(s->hd, cluster_offset, out_buf, out_len) != out_len) { 862 if (bdrv_pwrite(s->hd, cluster_offset, out_buf, out_len) != out_len) {
@@ -864,7 +864,7 @@ static int qcow_write_compressed(BlockDriverState *bs, int64_t sector_num, @@ -864,7 +864,7 @@ static int qcow_write_compressed(BlockDriverState *bs, int64_t sector_num,
864 return -1; 864 return -1;
865 } 865 }
866 } 866 }
867 - 867 +
868 qemu_free(out_buf); 868 qemu_free(out_buf);
869 return 0; 869 return 0;
870 } 870 }
block-qcow2.c
1 /* 1 /*
2 * Block driver for the QCOW version 2 format 2 * Block driver for the QCOW version 2 format
3 - * 3 + *
4 * Copyright (c) 2004-2006 Fabrice Bellard 4 * Copyright (c) 2004-2006 Fabrice Bellard
5 - * 5 + *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy 6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal 7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights 8 * in the Software without restriction, including without limitation the rights
@@ -34,10 +34,10 @@ @@ -34,10 +34,10 @@
34 - Memory management by reference counts. 34 - Memory management by reference counts.
35 - Clusters which have a reference count of one have the bit 35 - Clusters which have a reference count of one have the bit
36 QCOW_OFLAG_COPIED to optimize write performance. 36 QCOW_OFLAG_COPIED to optimize write performance.
37 - - Size of compressed clusters is stored in sectors to reduce bit usage 37 + - Size of compressed clusters is stored in sectors to reduce bit usage
38 in the cluster offsets. 38 in the cluster offsets.
39 - Support for storing additional data (such as the VM state) in the 39 - Support for storing additional data (such as the VM state) in the
40 - snapshots. 40 + snapshots.
41 - If a backing store is used, the cluster size is not constrained 41 - If a backing store is used, the cluster size is not constrained
42 (could be backported to QCOW). 42 (could be backported to QCOW).
43 - L2 tables have always a size of one cluster. 43 - L2 tables have always a size of one cluster.
@@ -45,7 +45,7 @@ @@ -45,7 +45,7 @@
45 45
46 //#define DEBUG_ALLOC 46 //#define DEBUG_ALLOC
47 //#define DEBUG_ALLOC2 47 //#define DEBUG_ALLOC2
48 - 48 +
49 #define QCOW_MAGIC (('Q' << 24) | ('F' << 16) | ('I' << 8) | 0xfb) 49 #define QCOW_MAGIC (('Q' << 24) | ('F' << 16) | ('I' << 8) | 0xfb)
50 #define QCOW_VERSION 2 50 #define QCOW_VERSION 2
51 51
@@ -152,22 +152,22 @@ typedef struct BDRVQcowState { @@ -152,22 +152,22 @@ typedef struct BDRVQcowState {
152 } BDRVQcowState; 152 } BDRVQcowState;
153 153
154 static int decompress_cluster(BDRVQcowState *s, uint64_t cluster_offset); 154 static int decompress_cluster(BDRVQcowState *s, uint64_t cluster_offset);
155 -static int qcow_read(BlockDriverState *bs, int64_t sector_num, 155 +static int qcow_read(BlockDriverState *bs, int64_t sector_num,
156 uint8_t *buf, int nb_sectors); 156 uint8_t *buf, int nb_sectors);
157 static int qcow_read_snapshots(BlockDriverState *bs); 157 static int qcow_read_snapshots(BlockDriverState *bs);
158 static void qcow_free_snapshots(BlockDriverState *bs); 158 static void qcow_free_snapshots(BlockDriverState *bs);
159 static int refcount_init(BlockDriverState *bs); 159 static int refcount_init(BlockDriverState *bs);
160 static void refcount_close(BlockDriverState *bs); 160 static void refcount_close(BlockDriverState *bs);
161 static int get_refcount(BlockDriverState *bs, int64_t cluster_index); 161 static int get_refcount(BlockDriverState *bs, int64_t cluster_index);
162 -static int update_cluster_refcount(BlockDriverState *bs, 162 +static int update_cluster_refcount(BlockDriverState *bs,
163 int64_t cluster_index, 163 int64_t cluster_index,
164 int addend); 164 int addend);
165 -static void update_refcount(BlockDriverState *bs,  
166 - int64_t offset, int64_t length, 165 +static void update_refcount(BlockDriverState *bs,
  166 + int64_t offset, int64_t length,
167 int addend); 167 int addend);
168 static int64_t alloc_clusters(BlockDriverState *bs, int64_t size); 168 static int64_t alloc_clusters(BlockDriverState *bs, int64_t size);
169 static int64_t alloc_bytes(BlockDriverState *bs, int size); 169 static int64_t alloc_bytes(BlockDriverState *bs, int size);
170 -static void free_clusters(BlockDriverState *bs, 170 +static void free_clusters(BlockDriverState *bs,
171 int64_t offset, int64_t size); 171 int64_t offset, int64_t size);
172 #ifdef DEBUG_ALLOC 172 #ifdef DEBUG_ALLOC
173 static void check_refcounts(BlockDriverState *bs); 173 static void check_refcounts(BlockDriverState *bs);
@@ -176,10 +176,10 @@ static void check_refcounts(BlockDriverState *bs); @@ -176,10 +176,10 @@ static void check_refcounts(BlockDriverState *bs);
176 static int qcow_probe(const uint8_t *buf, int buf_size, const char *filename) 176 static int qcow_probe(const uint8_t *buf, int buf_size, const char *filename)
177 { 177 {
178 const QCowHeader *cow_header = (const void *)buf; 178 const QCowHeader *cow_header = (const void *)buf;
179 - 179 +
180 if (buf_size >= sizeof(QCowHeader) && 180 if (buf_size >= sizeof(QCowHeader) &&
181 be32_to_cpu(cow_header->magic) == QCOW_MAGIC && 181 be32_to_cpu(cow_header->magic) == QCOW_MAGIC &&
182 - be32_to_cpu(cow_header->version) == QCOW_VERSION) 182 + be32_to_cpu(cow_header->version) == QCOW_VERSION)
183 return 100; 183 return 100;
184 else 184 else
185 return 0; 185 return 0;
@@ -209,11 +209,11 @@ static int qcow_open(BlockDriverState *bs, const char *filename, int flags) @@ -209,11 +209,11 @@ static int qcow_open(BlockDriverState *bs, const char *filename, int flags)
209 be32_to_cpus(&header.refcount_table_clusters); 209 be32_to_cpus(&header.refcount_table_clusters);
210 be64_to_cpus(&header.snapshots_offset); 210 be64_to_cpus(&header.snapshots_offset);
211 be32_to_cpus(&header.nb_snapshots); 211 be32_to_cpus(&header.nb_snapshots);
212 - 212 +
213 if (header.magic != QCOW_MAGIC || header.version != QCOW_VERSION) 213 if (header.magic != QCOW_MAGIC || header.version != QCOW_VERSION)
214 goto fail; 214 goto fail;
215 - if (header.size <= 1 ||  
216 - header.cluster_bits < 9 || 215 + if (header.size <= 1 ||
  216 + header.cluster_bits < 9 ||
217 header.cluster_bits > 16) 217 header.cluster_bits > 16)
218 goto fail; 218 goto fail;
219 if (header.crypt_method > QCOW_CRYPT_AES) 219 if (header.crypt_method > QCOW_CRYPT_AES)
@@ -231,7 +231,7 @@ static int qcow_open(BlockDriverState *bs, const char *filename, int flags) @@ -231,7 +231,7 @@ static int qcow_open(BlockDriverState *bs, const char *filename, int flags)
231 s->csize_mask = (1 << (s->cluster_bits - 8)) - 1; 231 s->csize_mask = (1 << (s->cluster_bits - 8)) - 1;
232 s->cluster_offset_mask = (1LL << s->csize_shift) - 1; 232 s->cluster_offset_mask = (1LL << s->csize_shift) - 1;
233 s->refcount_table_offset = header.refcount_table_offset; 233 s->refcount_table_offset = header.refcount_table_offset;
234 - s->refcount_table_size = 234 + s->refcount_table_size =
235 header.refcount_table_clusters << (s->cluster_bits - 3); 235 header.refcount_table_clusters << (s->cluster_bits - 3);
236 236
237 s->snapshots_offset = header.snapshots_offset; 237 s->snapshots_offset = header.snapshots_offset;
@@ -249,7 +249,7 @@ static int qcow_open(BlockDriverState *bs, const char *filename, int flags) @@ -249,7 +249,7 @@ static int qcow_open(BlockDriverState *bs, const char *filename, int flags)
249 s->l1_table = qemu_malloc(s->l1_size * sizeof(uint64_t)); 249 s->l1_table = qemu_malloc(s->l1_size * sizeof(uint64_t));
250 if (!s->l1_table) 250 if (!s->l1_table)
251 goto fail; 251 goto fail;
252 - if (bdrv_pread(s->hd, s->l1_table_offset, s->l1_table, s->l1_size * sizeof(uint64_t)) != 252 + if (bdrv_pread(s->hd, s->l1_table_offset, s->l1_table, s->l1_size * sizeof(uint64_t)) !=
253 s->l1_size * sizeof(uint64_t)) 253 s->l1_size * sizeof(uint64_t))
254 goto fail; 254 goto fail;
255 for(i = 0;i < s->l1_size; i++) { 255 for(i = 0;i < s->l1_size; i++) {
@@ -267,7 +267,7 @@ static int qcow_open(BlockDriverState *bs, const char *filename, int flags) @@ -267,7 +267,7 @@ static int qcow_open(BlockDriverState *bs, const char *filename, int flags)
267 if (!s->cluster_data) 267 if (!s->cluster_data)
268 goto fail; 268 goto fail;
269 s->cluster_cache_offset = -1; 269 s->cluster_cache_offset = -1;
270 - 270 +
271 if (refcount_init(bs) < 0) 271 if (refcount_init(bs) < 0)
272 goto fail; 272 goto fail;
273 273
@@ -304,7 +304,7 @@ static int qcow_set_key(BlockDriverState *bs, const char *key) @@ -304,7 +304,7 @@ static int qcow_set_key(BlockDriverState *bs, const char *key)
304 BDRVQcowState *s = bs->opaque; 304 BDRVQcowState *s = bs->opaque;
305 uint8_t keybuf[16]; 305 uint8_t keybuf[16];
306 int len, i; 306 int len, i;
307 - 307 +
308 memset(keybuf, 0, 16); 308 memset(keybuf, 0, 16);
309 len = strlen(key); 309 len = strlen(key);
310 if (len > 16) 310 if (len > 16)
@@ -358,7 +358,7 @@ static void encrypt_sectors(BDRVQcowState *s, int64_t sector_num, @@ -358,7 +358,7 @@ static void encrypt_sectors(BDRVQcowState *s, int64_t sector_num,
358 for(i = 0; i < nb_sectors; i++) { 358 for(i = 0; i < nb_sectors; i++) {
359 ivec.ll[0] = cpu_to_le64(sector_num); 359 ivec.ll[0] = cpu_to_le64(sector_num);
360 ivec.ll[1] = 0; 360 ivec.ll[1] = 0;
361 - AES_cbc_encrypt(in_buf, out_buf, 512, key, 361 + AES_cbc_encrypt(in_buf, out_buf, 512, key,
362 ivec.b, enc); 362 ivec.b, enc);
363 sector_num++; 363 sector_num++;
364 in_buf += 512; 364 in_buf += 512;
@@ -379,12 +379,12 @@ static int copy_sectors(BlockDriverState *bs, uint64_t start_sect, @@ -379,12 +379,12 @@ static int copy_sectors(BlockDriverState *bs, uint64_t start_sect,
379 if (ret < 0) 379 if (ret < 0)
380 return ret; 380 return ret;
381 if (s->crypt_method) { 381 if (s->crypt_method) {
382 - encrypt_sectors(s, start_sect + n_start,  
383 - s->cluster_data, 382 + encrypt_sectors(s, start_sect + n_start,
  383 + s->cluster_data,
384 s->cluster_data, n, 1, 384 s->cluster_data, n, 1,
385 &s->aes_encrypt_key); 385 &s->aes_encrypt_key);
386 } 386 }
387 - ret = bdrv_write(s->hd, (cluster_offset >> 9) + n_start, 387 + ret = bdrv_write(s->hd, (cluster_offset >> 9) + n_start,
388 s->cluster_data, n); 388 s->cluster_data, n);
389 if (ret < 0) 389 if (ret < 0)
390 return ret; 390 return ret;
@@ -451,7 +451,7 @@ static int grow_l1_table(BlockDriverState *bs, int min_size) @@ -451,7 +451,7 @@ static int grow_l1_table(BlockDriverState *bs, int min_size)
451 451
452 /* write new table (align to cluster) */ 452 /* write new table (align to cluster) */
453 new_l1_table_offset = alloc_clusters(bs, new_l1_size2); 453 new_l1_table_offset = alloc_clusters(bs, new_l1_size2);
454 - 454 +
455 for(i = 0; i < s->l1_size; i++) 455 for(i = 0; i < s->l1_size; i++)
456 new_l1_table[i] = cpu_to_be64(new_l1_table[i]); 456 new_l1_table[i] = cpu_to_be64(new_l1_table[i]);
457 ret = bdrv_pwrite(s->hd, new_l1_table_offset, new_l1_table, new_l1_size2); 457 ret = bdrv_pwrite(s->hd, new_l1_table_offset, new_l1_table, new_l1_size2);
@@ -459,7 +459,7 @@ static int grow_l1_table(BlockDriverState *bs, int min_size) @@ -459,7 +459,7 @@ static int grow_l1_table(BlockDriverState *bs, int min_size)
459 goto fail; 459 goto fail;
460 for(i = 0; i < s->l1_size; i++) 460 for(i = 0; i < s->l1_size; i++)
461 new_l1_table[i] = be64_to_cpu(new_l1_table[i]); 461 new_l1_table[i] = be64_to_cpu(new_l1_table[i]);
462 - 462 +
463 /* set new table */ 463 /* set new table */
464 data64 = cpu_to_be64(new_l1_table_offset); 464 data64 = cpu_to_be64(new_l1_table_offset);
465 if (bdrv_pwrite(s->hd, offsetof(QCowHeader, l1_table_offset), 465 if (bdrv_pwrite(s->hd, offsetof(QCowHeader, l1_table_offset),
@@ -489,7 +489,7 @@ static int grow_l1_table(BlockDriverState *bs, int min_size) @@ -489,7 +489,7 @@ static int grow_l1_table(BlockDriverState *bs, int min_size)
489 * 489 *
490 * 2 to allocate a compressed cluster of size 490 * 2 to allocate a compressed cluster of size
491 * 'compressed_size'. 'compressed_size' must be > 0 and < 491 * 'compressed_size'. 'compressed_size' must be > 0 and <
492 - * cluster_size 492 + * cluster_size
493 * 493 *
494 * return 0 if not allocated. 494 * return 0 if not allocated.
495 */ 495 */
@@ -501,7 +501,7 @@ static uint64_t get_cluster_offset(BlockDriverState *bs, @@ -501,7 +501,7 @@ static uint64_t get_cluster_offset(BlockDriverState *bs,
501 BDRVQcowState *s = bs->opaque; 501 BDRVQcowState *s = bs->opaque;
502 int min_index, i, j, l1_index, l2_index, ret; 502 int min_index, i, j, l1_index, l2_index, ret;
503 uint64_t l2_offset, *l2_table, cluster_offset, tmp, old_l2_offset; 503 uint64_t l2_offset, *l2_table, cluster_offset, tmp, old_l2_offset;
504 - 504 +
505 l1_index = offset >> (s->l2_bits + s->cluster_bits); 505 l1_index = offset >> (s->l2_bits + s->cluster_bits);
506 if (l1_index >= s->l1_size) { 506 if (l1_index >= s->l1_size) {
507 /* outside l1 table is allowed: we grow the table if needed */ 507 /* outside l1 table is allowed: we grow the table if needed */
@@ -521,7 +521,7 @@ static uint64_t get_cluster_offset(BlockDriverState *bs, @@ -521,7 +521,7 @@ static uint64_t get_cluster_offset(BlockDriverState *bs,
521 /* update the L1 entry */ 521 /* update the L1 entry */
522 s->l1_table[l1_index] = l2_offset | QCOW_OFLAG_COPIED; 522 s->l1_table[l1_index] = l2_offset | QCOW_OFLAG_COPIED;
523 tmp = cpu_to_be64(l2_offset | QCOW_OFLAG_COPIED); 523 tmp = cpu_to_be64(l2_offset | QCOW_OFLAG_COPIED);
524 - if (bdrv_pwrite(s->hd, s->l1_table_offset + l1_index * sizeof(tmp), 524 + if (bdrv_pwrite(s->hd, s->l1_table_offset + l1_index * sizeof(tmp),
525 &tmp, sizeof(tmp)) != sizeof(tmp)) 525 &tmp, sizeof(tmp)) != sizeof(tmp))
526 return 0; 526 return 0;
527 min_index = l2_cache_new_entry(bs); 527 min_index = l2_cache_new_entry(bs);
@@ -530,12 +530,12 @@ static uint64_t get_cluster_offset(BlockDriverState *bs, @@ -530,12 +530,12 @@ static uint64_t get_cluster_offset(BlockDriverState *bs,
530 if (old_l2_offset == 0) { 530 if (old_l2_offset == 0) {
531 memset(l2_table, 0, s->l2_size * sizeof(uint64_t)); 531 memset(l2_table, 0, s->l2_size * sizeof(uint64_t));
532 } else { 532 } else {
533 - if (bdrv_pread(s->hd, old_l2_offset, 533 + if (bdrv_pread(s->hd, old_l2_offset,
534 l2_table, s->l2_size * sizeof(uint64_t)) != 534 l2_table, s->l2_size * sizeof(uint64_t)) !=
535 s->l2_size * sizeof(uint64_t)) 535 s->l2_size * sizeof(uint64_t))
536 return 0; 536 return 0;
537 } 537 }
538 - if (bdrv_pwrite(s->hd, l2_offset, 538 + if (bdrv_pwrite(s->hd, l2_offset,
539 l2_table, s->l2_size * sizeof(uint64_t)) != 539 l2_table, s->l2_size * sizeof(uint64_t)) !=
540 s->l2_size * sizeof(uint64_t)) 540 s->l2_size * sizeof(uint64_t))
541 return 0; 541 return 0;
@@ -563,7 +563,7 @@ static uint64_t get_cluster_offset(BlockDriverState *bs, @@ -563,7 +563,7 @@ static uint64_t get_cluster_offset(BlockDriverState *bs,
563 /* not found: load a new entry in the least used one */ 563 /* not found: load a new entry in the least used one */
564 min_index = l2_cache_new_entry(bs); 564 min_index = l2_cache_new_entry(bs);
565 l2_table = s->l2_cache + (min_index << s->l2_bits); 565 l2_table = s->l2_cache + (min_index << s->l2_bits);
566 - if (bdrv_pread(s->hd, l2_offset, l2_table, s->l2_size * sizeof(uint64_t)) != 566 + if (bdrv_pread(s->hd, l2_offset, l2_table, s->l2_size * sizeof(uint64_t)) !=
567 s->l2_size * sizeof(uint64_t)) 567 s->l2_size * sizeof(uint64_t))
568 return 0; 568 return 0;
569 } 569 }
@@ -581,7 +581,7 @@ static uint64_t get_cluster_offset(BlockDriverState *bs, @@ -581,7 +581,7 @@ static uint64_t get_cluster_offset(BlockDriverState *bs,
581 /* free the cluster */ 581 /* free the cluster */
582 if (cluster_offset & QCOW_OFLAG_COMPRESSED) { 582 if (cluster_offset & QCOW_OFLAG_COMPRESSED) {
583 int nb_csectors; 583 int nb_csectors;
584 - nb_csectors = ((cluster_offset >> s->csize_shift) & 584 + nb_csectors = ((cluster_offset >> s->csize_shift) &
585 s->csize_mask) + 1; 585 s->csize_mask) + 1;
586 free_clusters(bs, (cluster_offset & s->cluster_offset_mask) & ~511, 586 free_clusters(bs, (cluster_offset & s->cluster_offset_mask) & ~511,
587 nb_csectors * 512); 587 nb_csectors * 512);
@@ -600,7 +600,7 @@ static uint64_t get_cluster_offset(BlockDriverState *bs, @@ -600,7 +600,7 @@ static uint64_t get_cluster_offset(BlockDriverState *bs,
600 written */ 600 written */
601 if ((n_end - n_start) < s->cluster_sectors) { 601 if ((n_end - n_start) < s->cluster_sectors) {
602 uint64_t start_sect; 602 uint64_t start_sect;
603 - 603 +
604 start_sect = (offset & ~(s->cluster_size - 1)) >> 9; 604 start_sect = (offset & ~(s->cluster_size - 1)) >> 9;
605 ret = copy_sectors(bs, start_sect, 605 ret = copy_sectors(bs, start_sect,
606 cluster_offset, 0, n_start); 606 cluster_offset, 0, n_start);
@@ -615,22 +615,22 @@ static uint64_t get_cluster_offset(BlockDriverState *bs, @@ -615,22 +615,22 @@ static uint64_t get_cluster_offset(BlockDriverState *bs,
615 } else { 615 } else {
616 int nb_csectors; 616 int nb_csectors;
617 cluster_offset = alloc_bytes(bs, compressed_size); 617 cluster_offset = alloc_bytes(bs, compressed_size);
618 - nb_csectors = ((cluster_offset + compressed_size - 1) >> 9) - 618 + nb_csectors = ((cluster_offset + compressed_size - 1) >> 9) -
619 (cluster_offset >> 9); 619 (cluster_offset >> 9);
620 - cluster_offset |= QCOW_OFLAG_COMPRESSED | 620 + cluster_offset |= QCOW_OFLAG_COMPRESSED |
621 ((uint64_t)nb_csectors << s->csize_shift); 621 ((uint64_t)nb_csectors << s->csize_shift);
622 /* compressed clusters never have the copied flag */ 622 /* compressed clusters never have the copied flag */
623 tmp = cpu_to_be64(cluster_offset); 623 tmp = cpu_to_be64(cluster_offset);
624 } 624 }
625 /* update L2 table */ 625 /* update L2 table */
626 l2_table[l2_index] = tmp; 626 l2_table[l2_index] = tmp;
627 - if (bdrv_pwrite(s->hd, 627 + if (bdrv_pwrite(s->hd,
628 l2_offset + l2_index * sizeof(tmp), &tmp, sizeof(tmp)) != sizeof(tmp)) 628 l2_offset + l2_index * sizeof(tmp), &tmp, sizeof(tmp)) != sizeof(tmp))
629 return 0; 629 return 0;
630 return cluster_offset; 630 return cluster_offset;
631 } 631 }
632 632
633 -static int qcow_is_allocated(BlockDriverState *bs, int64_t sector_num, 633 +static int qcow_is_allocated(BlockDriverState *bs, int64_t sector_num,
634 int nb_sectors, int *pnum) 634 int nb_sectors, int *pnum)
635 { 635 {
636 BDRVQcowState *s = bs->opaque; 636 BDRVQcowState *s = bs->opaque;
@@ -672,7 +672,7 @@ static int decompress_buffer(uint8_t *out_buf, int out_buf_size, @@ -672,7 +672,7 @@ static int decompress_buffer(uint8_t *out_buf, int out_buf_size,
672 inflateEnd(strm); 672 inflateEnd(strm);
673 return 0; 673 return 0;
674 } 674 }
675 - 675 +
676 static int decompress_cluster(BDRVQcowState *s, uint64_t cluster_offset) 676 static int decompress_cluster(BDRVQcowState *s, uint64_t cluster_offset)
677 { 677 {
678 int ret, csize, nb_csectors, sector_offset; 678 int ret, csize, nb_csectors, sector_offset;
@@ -697,7 +697,7 @@ static int decompress_cluster(BDRVQcowState *s, uint64_t cluster_offset) @@ -697,7 +697,7 @@ static int decompress_cluster(BDRVQcowState *s, uint64_t cluster_offset)
697 } 697 }
698 698
699 /* handle reading after the end of the backing file */ 699 /* handle reading after the end of the backing file */
700 -static int backing_read1(BlockDriverState *bs, 700 +static int backing_read1(BlockDriverState *bs,
701 int64_t sector_num, uint8_t *buf, int nb_sectors) 701 int64_t sector_num, uint8_t *buf, int nb_sectors)
702 { 702 {
703 int n1; 703 int n1;
@@ -711,13 +711,13 @@ static int backing_read1(BlockDriverState *bs, @@ -711,13 +711,13 @@ static int backing_read1(BlockDriverState *bs,
711 return n1; 711 return n1;
712 } 712 }
713 713
714 -static int qcow_read(BlockDriverState *bs, int64_t sector_num, 714 +static int qcow_read(BlockDriverState *bs, int64_t sector_num,
715 uint8_t *buf, int nb_sectors) 715 uint8_t *buf, int nb_sectors)
716 { 716 {
717 BDRVQcowState *s = bs->opaque; 717 BDRVQcowState *s = bs->opaque;
718 int ret, index_in_cluster, n, n1; 718 int ret, index_in_cluster, n, n1;
719 uint64_t cluster_offset; 719 uint64_t cluster_offset;
720 - 720 +
721 while (nb_sectors > 0) { 721 while (nb_sectors > 0) {
722 cluster_offset = get_cluster_offset(bs, sector_num << 9, 0, 0, 0, 0); 722 cluster_offset = get_cluster_offset(bs, sector_num << 9, 0, 0, 0, 0);
723 index_in_cluster = sector_num & (s->cluster_sectors - 1); 723 index_in_cluster = sector_num & (s->cluster_sectors - 1);
@@ -742,10 +742,10 @@ static int qcow_read(BlockDriverState *bs, int64_t sector_num, @@ -742,10 +742,10 @@ static int qcow_read(BlockDriverState *bs, int64_t sector_num,
742 memcpy(buf, s->cluster_cache + index_in_cluster * 512, 512 * n); 742 memcpy(buf, s->cluster_cache + index_in_cluster * 512, 512 * n);
743 } else { 743 } else {
744 ret = bdrv_pread(s->hd, cluster_offset + index_in_cluster * 512, buf, n * 512); 744 ret = bdrv_pread(s->hd, cluster_offset + index_in_cluster * 512, buf, n * 512);
745 - if (ret != n * 512) 745 + if (ret != n * 512)
746 return -1; 746 return -1;
747 if (s->crypt_method) { 747 if (s->crypt_method) {
748 - encrypt_sectors(s, sector_num, buf, buf, n, 0, 748 + encrypt_sectors(s, sector_num, buf, buf, n, 0,
749 &s->aes_decrypt_key); 749 &s->aes_decrypt_key);
750 } 750 }
751 } 751 }
@@ -756,32 +756,32 @@ static int qcow_read(BlockDriverState *bs, int64_t sector_num, @@ -756,32 +756,32 @@ static int qcow_read(BlockDriverState *bs, int64_t sector_num,
756 return 0; 756 return 0;
757 } 757 }
758 758
759 -static int qcow_write(BlockDriverState *bs, int64_t sector_num, 759 +static int qcow_write(BlockDriverState *bs, int64_t sector_num,
760 const uint8_t *buf, int nb_sectors) 760 const uint8_t *buf, int nb_sectors)
761 { 761 {
762 BDRVQcowState *s = bs->opaque; 762 BDRVQcowState *s = bs->opaque;
763 int ret, index_in_cluster, n; 763 int ret, index_in_cluster, n;
764 uint64_t cluster_offset; 764 uint64_t cluster_offset;
765 - 765 +
766 while (nb_sectors > 0) { 766 while (nb_sectors > 0) {
767 index_in_cluster = sector_num & (s->cluster_sectors - 1); 767 index_in_cluster = sector_num & (s->cluster_sectors - 1);
768 n = s->cluster_sectors - index_in_cluster; 768 n = s->cluster_sectors - index_in_cluster;
769 if (n > nb_sectors) 769 if (n > nb_sectors)
770 n = nb_sectors; 770 n = nb_sectors;
771 - cluster_offset = get_cluster_offset(bs, sector_num << 9, 1, 0,  
772 - index_in_cluster, 771 + cluster_offset = get_cluster_offset(bs, sector_num << 9, 1, 0,
  772 + index_in_cluster,
773 index_in_cluster + n); 773 index_in_cluster + n);
774 if (!cluster_offset) 774 if (!cluster_offset)
775 return -1; 775 return -1;
776 if (s->crypt_method) { 776 if (s->crypt_method) {
777 encrypt_sectors(s, sector_num, s->cluster_data, buf, n, 1, 777 encrypt_sectors(s, sector_num, s->cluster_data, buf, n, 1,
778 &s->aes_encrypt_key); 778 &s->aes_encrypt_key);
779 - ret = bdrv_pwrite(s->hd, cluster_offset + index_in_cluster * 512, 779 + ret = bdrv_pwrite(s->hd, cluster_offset + index_in_cluster * 512,
780 s->cluster_data, n * 512); 780 s->cluster_data, n * 512);
781 } else { 781 } else {
782 ret = bdrv_pwrite(s->hd, cluster_offset + index_in_cluster * 512, buf, n * 512); 782 ret = bdrv_pwrite(s->hd, cluster_offset + index_in_cluster * 512, buf, n * 512);
783 } 783 }
784 - if (ret != n * 512) 784 + if (ret != n * 512)
785 return -1; 785 return -1;
786 nb_sectors -= n; 786 nb_sectors -= n;
787 sector_num += n; 787 sector_num += n;
@@ -798,7 +798,7 @@ typedef struct QCowAIOCB { @@ -798,7 +798,7 @@ typedef struct QCowAIOCB {
798 int nb_sectors; 798 int nb_sectors;
799 int n; 799 int n;
800 uint64_t cluster_offset; 800 uint64_t cluster_offset;
801 - uint8_t *cluster_data; 801 + uint8_t *cluster_data;
802 BlockDriverAIOCB *hd_aiocb; 802 BlockDriverAIOCB *hd_aiocb;
803 } QCowAIOCB; 803 } QCowAIOCB;
804 804
@@ -825,8 +825,8 @@ static void qcow_aio_read_cb(void *opaque, int ret) @@ -825,8 +825,8 @@ static void qcow_aio_read_cb(void *opaque, int ret)
825 /* nothing to do */ 825 /* nothing to do */
826 } else { 826 } else {
827 if (s->crypt_method) { 827 if (s->crypt_method) {
828 - encrypt_sectors(s, acb->sector_num, acb->buf, acb->buf,  
829 - acb->n, 0, 828 + encrypt_sectors(s, acb->sector_num, acb->buf, acb->buf,
  829 + acb->n, 0,
830 &s->aes_decrypt_key); 830 &s->aes_decrypt_key);
831 } 831 }
832 } 832 }
@@ -841,9 +841,9 @@ static void qcow_aio_read_cb(void *opaque, int ret) @@ -841,9 +841,9 @@ static void qcow_aio_read_cb(void *opaque, int ret)
841 qemu_aio_release(acb); 841 qemu_aio_release(acb);
842 return; 842 return;
843 } 843 }
844 - 844 +
845 /* prepare next AIO request */ 845 /* prepare next AIO request */
846 - acb->cluster_offset = get_cluster_offset(bs, acb->sector_num << 9, 846 + acb->cluster_offset = get_cluster_offset(bs, acb->sector_num << 9,
847 0, 0, 0, 0); 847 0, 0, 0, 0);
848 index_in_cluster = acb->sector_num & (s->cluster_sectors - 1); 848 index_in_cluster = acb->sector_num & (s->cluster_sectors - 1);
849 acb->n = s->cluster_sectors - index_in_cluster; 849 acb->n = s->cluster_sectors - index_in_cluster;
@@ -853,10 +853,10 @@ static void qcow_aio_read_cb(void *opaque, int ret) @@ -853,10 +853,10 @@ static void qcow_aio_read_cb(void *opaque, int ret)
853 if (!acb->cluster_offset) { 853 if (!acb->cluster_offset) {
854 if (bs->backing_hd) { 854 if (bs->backing_hd) {
855 /* read from the base image */ 855 /* read from the base image */
856 - n1 = backing_read1(bs->backing_hd, acb->sector_num, 856 + n1 = backing_read1(bs->backing_hd, acb->sector_num,
857 acb->buf, acb->n); 857 acb->buf, acb->n);
858 if (n1 > 0) { 858 if (n1 > 0) {
859 - acb->hd_aiocb = bdrv_aio_read(bs->backing_hd, acb->sector_num, 859 + acb->hd_aiocb = bdrv_aio_read(bs->backing_hd, acb->sector_num,
860 acb->buf, acb->n, qcow_aio_read_cb, acb); 860 acb->buf, acb->n, qcow_aio_read_cb, acb);
861 if (acb->hd_aiocb == NULL) 861 if (acb->hd_aiocb == NULL)
862 goto fail; 862 goto fail;
@@ -872,7 +872,7 @@ static void qcow_aio_read_cb(void *opaque, int ret) @@ -872,7 +872,7 @@ static void qcow_aio_read_cb(void *opaque, int ret)
872 /* add AIO support for compressed blocks ? */ 872 /* add AIO support for compressed blocks ? */
873 if (decompress_cluster(s, acb->cluster_offset) < 0) 873 if (decompress_cluster(s, acb->cluster_offset) < 0)
874 goto fail; 874 goto fail;
875 - memcpy(acb->buf, 875 + memcpy(acb->buf,
876 s->cluster_cache + index_in_cluster * 512, 512 * acb->n); 876 s->cluster_cache + index_in_cluster * 512, 512 * acb->n);
877 goto redo; 877 goto redo;
878 } else { 878 } else {
@@ -881,7 +881,7 @@ static void qcow_aio_read_cb(void *opaque, int ret) @@ -881,7 +881,7 @@ static void qcow_aio_read_cb(void *opaque, int ret)
881 goto fail; 881 goto fail;
882 } 882 }
883 acb->hd_aiocb = bdrv_aio_read(s->hd, 883 acb->hd_aiocb = bdrv_aio_read(s->hd,
884 - (acb->cluster_offset >> 9) + index_in_cluster, 884 + (acb->cluster_offset >> 9) + index_in_cluster,
885 acb->buf, acb->n, qcow_aio_read_cb, acb); 885 acb->buf, acb->n, qcow_aio_read_cb, acb);
886 if (acb->hd_aiocb == NULL) 886 if (acb->hd_aiocb == NULL)
887 goto fail; 887 goto fail;
@@ -948,13 +948,13 @@ static void qcow_aio_write_cb(void *opaque, int ret) @@ -948,13 +948,13 @@ static void qcow_aio_write_cb(void *opaque, int ret)
948 qemu_aio_release(acb); 948 qemu_aio_release(acb);
949 return; 949 return;
950 } 950 }
951 - 951 +
952 index_in_cluster = acb->sector_num & (s->cluster_sectors - 1); 952 index_in_cluster = acb->sector_num & (s->cluster_sectors - 1);
953 acb->n = s->cluster_sectors - index_in_cluster; 953 acb->n = s->cluster_sectors - index_in_cluster;
954 if (acb->n > acb->nb_sectors) 954 if (acb->n > acb->nb_sectors)
955 acb->n = acb->nb_sectors; 955 acb->n = acb->nb_sectors;
956 - cluster_offset = get_cluster_offset(bs, acb->sector_num << 9, 1, 0,  
957 - index_in_cluster, 956 + cluster_offset = get_cluster_offset(bs, acb->sector_num << 9, 1, 0,
  957 + index_in_cluster,
958 index_in_cluster + acb->n); 958 index_in_cluster + acb->n);
959 if (!cluster_offset || (cluster_offset & 511) != 0) { 959 if (!cluster_offset || (cluster_offset & 511) != 0) {
960 ret = -EIO; 960 ret = -EIO;
@@ -968,15 +968,15 @@ static void qcow_aio_write_cb(void *opaque, int ret) @@ -968,15 +968,15 @@ static void qcow_aio_write_cb(void *opaque, int ret)
968 goto fail; 968 goto fail;
969 } 969 }
970 } 970 }
971 - encrypt_sectors(s, acb->sector_num, acb->cluster_data, acb->buf, 971 + encrypt_sectors(s, acb->sector_num, acb->cluster_data, acb->buf,
972 acb->n, 1, &s->aes_encrypt_key); 972 acb->n, 1, &s->aes_encrypt_key);
973 src_buf = acb->cluster_data; 973 src_buf = acb->cluster_data;
974 } else { 974 } else {
975 src_buf = acb->buf; 975 src_buf = acb->buf;
976 } 976 }
977 acb->hd_aiocb = bdrv_aio_write(s->hd, 977 acb->hd_aiocb = bdrv_aio_write(s->hd,
978 - (cluster_offset >> 9) + index_in_cluster,  
979 - src_buf, acb->n, 978 + (cluster_offset >> 9) + index_in_cluster,
  979 + src_buf, acb->n,
980 qcow_aio_write_cb, acb); 980 qcow_aio_write_cb, acb);
981 if (acb->hd_aiocb == NULL) 981 if (acb->hd_aiocb == NULL)
982 goto fail; 982 goto fail;
@@ -988,13 +988,13 @@ static BlockDriverAIOCB *qcow_aio_write(BlockDriverState *bs, @@ -988,13 +988,13 @@ static BlockDriverAIOCB *qcow_aio_write(BlockDriverState *bs,
988 { 988 {
989 BDRVQcowState *s = bs->opaque; 989 BDRVQcowState *s = bs->opaque;
990 QCowAIOCB *acb; 990 QCowAIOCB *acb;
991 - 991 +
992 s->cluster_cache_offset = -1; /* disable compressed cache */ 992 s->cluster_cache_offset = -1; /* disable compressed cache */
993 993
994 acb = qcow_aio_setup(bs, sector_num, (uint8_t*)buf, nb_sectors, cb, opaque); 994 acb = qcow_aio_setup(bs, sector_num, (uint8_t*)buf, nb_sectors, cb, opaque);
995 if (!acb) 995 if (!acb)
996 return NULL; 996 return NULL;
997 - 997 +
998 qcow_aio_write_cb(acb, 0); 998 qcow_aio_write_cb(acb, 0);
999 return &acb->common; 999 return &acb->common;
1000 } 1000 }
@@ -1038,7 +1038,7 @@ static void create_refcount_update(QCowCreateState *s, @@ -1038,7 +1038,7 @@ static void create_refcount_update(QCowCreateState *s,
1038 1038
1039 start = offset & ~(s->cluster_size - 1); 1039 start = offset & ~(s->cluster_size - 1);
1040 last = (offset + size - 1) & ~(s->cluster_size - 1); 1040 last = (offset + size - 1) & ~(s->cluster_size - 1);
1041 - for(cluster_offset = start; cluster_offset <= last; 1041 + for(cluster_offset = start; cluster_offset <= last;
1042 cluster_offset += s->cluster_size) { 1042 cluster_offset += s->cluster_size) {
1043 p = &s->refcount_block[cluster_offset >> s->cluster_bits]; 1043 p = &s->refcount_block[cluster_offset >> s->cluster_bits];
1044 refcount = be16_to_cpu(*p); 1044 refcount = be16_to_cpu(*p);
@@ -1054,7 +1054,7 @@ static int qcow_create(const char *filename, int64_t total_size, @@ -1054,7 +1054,7 @@ static int qcow_create(const char *filename, int64_t total_size,
1054 QCowHeader header; 1054 QCowHeader header;
1055 uint64_t tmp, offset; 1055 uint64_t tmp, offset;
1056 QCowCreateState s1, *s = &s1; 1056 QCowCreateState s1, *s = &s1;
1057 - 1057 +
1058 memset(s, 0, sizeof(*s)); 1058 memset(s, 0, sizeof(*s));
1059 1059
1060 fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0644); 1060 fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0644);
@@ -1096,7 +1096,7 @@ static int qcow_create(const char *filename, int64_t total_size, @@ -1096,7 +1096,7 @@ static int qcow_create(const char *filename, int64_t total_size,
1096 s->refcount_block = qemu_mallocz(s->cluster_size); 1096 s->refcount_block = qemu_mallocz(s->cluster_size);
1097 if (!s->refcount_block) 1097 if (!s->refcount_block)
1098 goto fail; 1098 goto fail;
1099 - 1099 +
1100 s->refcount_table_offset = offset; 1100 s->refcount_table_offset = offset;
1101 header.refcount_table_offset = cpu_to_be64(offset); 1101 header.refcount_table_offset = cpu_to_be64(offset);
1102 header.refcount_table_clusters = cpu_to_be32(1); 1102 header.refcount_table_clusters = cpu_to_be32(1);
@@ -1111,7 +1111,7 @@ static int qcow_create(const char *filename, int64_t total_size, @@ -1111,7 +1111,7 @@ static int qcow_create(const char *filename, int64_t total_size,
1111 create_refcount_update(s, s->l1_table_offset, l1_size * sizeof(uint64_t)); 1111 create_refcount_update(s, s->l1_table_offset, l1_size * sizeof(uint64_t));
1112 create_refcount_update(s, s->refcount_table_offset, s->cluster_size); 1112 create_refcount_update(s, s->refcount_table_offset, s->cluster_size);
1113 create_refcount_update(s, s->refcount_block_offset, s->cluster_size); 1113 create_refcount_update(s, s->refcount_block_offset, s->cluster_size);
1114 - 1114 +
1115 /* write all the data */ 1115 /* write all the data */
1116 write(fd, &header, sizeof(header)); 1116 write(fd, &header, sizeof(header));
1117 if (backing_file) { 1117 if (backing_file) {
@@ -1124,7 +1124,7 @@ static int qcow_create(const char *filename, int64_t total_size, @@ -1124,7 +1124,7 @@ static int qcow_create(const char *filename, int64_t total_size,
1124 } 1124 }
1125 lseek(fd, s->refcount_table_offset, SEEK_SET); 1125 lseek(fd, s->refcount_table_offset, SEEK_SET);
1126 write(fd, s->refcount_table, s->cluster_size); 1126 write(fd, s->refcount_table, s->cluster_size);
1127 - 1127 +
1128 lseek(fd, s->refcount_block_offset, SEEK_SET); 1128 lseek(fd, s->refcount_block_offset, SEEK_SET);
1129 write(fd, s->refcount_block, s->cluster_size); 1129 write(fd, s->refcount_block, s->cluster_size);
1130 1130
@@ -1153,7 +1153,7 @@ static int qcow_make_empty(BlockDriverState *bs) @@ -1153,7 +1153,7 @@ static int qcow_make_empty(BlockDriverState *bs)
1153 ret = bdrv_truncate(s->hd, s->l1_table_offset + l1_length); 1153 ret = bdrv_truncate(s->hd, s->l1_table_offset + l1_length);
1154 if (ret < 0) 1154 if (ret < 0)
1155 return ret; 1155 return ret;
1156 - 1156 +
1157 l2_cache_reset(bs); 1157 l2_cache_reset(bs);
1158 #endif 1158 #endif
1159 return 0; 1159 return 0;
@@ -1161,7 +1161,7 @@ static int qcow_make_empty(BlockDriverState *bs) @@ -1161,7 +1161,7 @@ static int qcow_make_empty(BlockDriverState *bs)
1161 1161
1162 /* XXX: put compressed sectors first, then all the cluster aligned 1162 /* XXX: put compressed sectors first, then all the cluster aligned
1163 tables to avoid losing bytes in alignment */ 1163 tables to avoid losing bytes in alignment */
1164 -static int qcow_write_compressed(BlockDriverState *bs, int64_t sector_num, 1164 +static int qcow_write_compressed(BlockDriverState *bs, int64_t sector_num,
1165 const uint8_t *buf, int nb_sectors) 1165 const uint8_t *buf, int nb_sectors)
1166 { 1166 {
1167 BDRVQcowState *s = bs->opaque; 1167 BDRVQcowState *s = bs->opaque;
@@ -1189,7 +1189,7 @@ static int qcow_write_compressed(BlockDriverState *bs, int64_t sector_num, @@ -1189,7 +1189,7 @@ static int qcow_write_compressed(BlockDriverState *bs, int64_t sector_num,
1189 /* best compression, small window, no zlib header */ 1189 /* best compression, small window, no zlib header */
1190 memset(&strm, 0, sizeof(strm)); 1190 memset(&strm, 0, sizeof(strm));
1191 ret = deflateInit2(&strm, Z_DEFAULT_COMPRESSION, 1191 ret = deflateInit2(&strm, Z_DEFAULT_COMPRESSION,
1192 - Z_DEFLATED, -12, 1192 + Z_DEFLATED, -12,
1193 9, Z_DEFAULT_STRATEGY); 1193 9, Z_DEFAULT_STRATEGY);
1194 if (ret != 0) { 1194 if (ret != 0) {
1195 qemu_free(out_buf); 1195 qemu_free(out_buf);
@@ -1215,7 +1215,7 @@ static int qcow_write_compressed(BlockDriverState *bs, int64_t sector_num, @@ -1215,7 +1215,7 @@ static int qcow_write_compressed(BlockDriverState *bs, int64_t sector_num,
1215 /* could not compress: write normal cluster */ 1215 /* could not compress: write normal cluster */
1216 qcow_write(bs, sector_num, buf, s->cluster_sectors); 1216 qcow_write(bs, sector_num, buf, s->cluster_sectors);
1217 } else { 1217 } else {
1218 - cluster_offset = get_cluster_offset(bs, sector_num << 9, 2, 1218 + cluster_offset = get_cluster_offset(bs, sector_num << 9, 2,
1219 out_len, 0, 0); 1219 out_len, 0, 0);
1220 cluster_offset &= s->cluster_offset_mask; 1220 cluster_offset &= s->cluster_offset_mask;
1221 if (bdrv_pwrite(s->hd, cluster_offset, out_buf, out_len) != out_len) { 1221 if (bdrv_pwrite(s->hd, cluster_offset, out_buf, out_len) != out_len) {
@@ -1223,7 +1223,7 @@ static int qcow_write_compressed(BlockDriverState *bs, int64_t sector_num, @@ -1223,7 +1223,7 @@ static int qcow_write_compressed(BlockDriverState *bs, int64_t sector_num,
1223 return -1; 1223 return -1;
1224 } 1224 }
1225 } 1225 }
1226 - 1226 +
1227 qemu_free(out_buf); 1227 qemu_free(out_buf);
1228 return 0; 1228 return 0;
1229 } 1229 }
@@ -1238,7 +1238,7 @@ static int qcow_get_info(BlockDriverState *bs, BlockDriverInfo *bdi) @@ -1238,7 +1238,7 @@ static int qcow_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
1238 { 1238 {
1239 BDRVQcowState *s = bs->opaque; 1239 BDRVQcowState *s = bs->opaque;
1240 bdi->cluster_size = s->cluster_size; 1240 bdi->cluster_size = s->cluster_size;
1241 - bdi->vm_state_offset = (int64_t)s->l1_vm_state_index << 1241 + bdi->vm_state_offset = (int64_t)s->l1_vm_state_index <<
1242 (s->cluster_bits + s->l2_bits); 1242 (s->cluster_bits + s->l2_bits);
1243 return 0; 1243 return 0;
1244 } 1244 }
@@ -1247,7 +1247,7 @@ static int qcow_get_info(BlockDriverState *bs, BlockDriverInfo *bdi) @@ -1247,7 +1247,7 @@ static int qcow_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
1247 /* snapshot support */ 1247 /* snapshot support */
1248 1248
1249 /* update the refcounts of snapshots and the copied flag */ 1249 /* update the refcounts of snapshots and the copied flag */
1250 -static int update_snapshot_refcount(BlockDriverState *bs, 1250 +static int update_snapshot_refcount(BlockDriverState *bs,
1251 int64_t l1_table_offset, 1251 int64_t l1_table_offset,
1252 int l1_size, 1252 int l1_size,
1253 int addend) 1253 int addend)
@@ -1256,7 +1256,7 @@ static int update_snapshot_refcount(BlockDriverState *bs, @@ -1256,7 +1256,7 @@ static int update_snapshot_refcount(BlockDriverState *bs,
1256 uint64_t *l1_table, *l2_table, l2_offset, offset, l1_size2, l1_allocated; 1256 uint64_t *l1_table, *l2_table, l2_offset, offset, l1_size2, l1_allocated;
1257 int64_t old_offset, old_l2_offset; 1257 int64_t old_offset, old_l2_offset;
1258 int l2_size, i, j, l1_modified, l2_modified, nb_csectors, refcount; 1258 int l2_size, i, j, l1_modified, l2_modified, nb_csectors, refcount;
1259 - 1259 +
1260 l2_cache_reset(bs); 1260 l2_cache_reset(bs);
1261 1261
1262 l2_table = NULL; 1262 l2_table = NULL;
@@ -1268,7 +1268,7 @@ static int update_snapshot_refcount(BlockDriverState *bs, @@ -1268,7 +1268,7 @@ static int update_snapshot_refcount(BlockDriverState *bs,
1268 if (!l1_table) 1268 if (!l1_table)
1269 goto fail; 1269 goto fail;
1270 l1_allocated = 1; 1270 l1_allocated = 1;
1271 - if (bdrv_pread(s->hd, l1_table_offset, 1271 + if (bdrv_pread(s->hd, l1_table_offset,
1272 l1_table, l1_size2) != l1_size2) 1272 l1_table, l1_size2) != l1_size2)
1273 goto fail; 1273 goto fail;
1274 for(i = 0;i < l1_size; i++) 1274 for(i = 0;i < l1_size; i++)
@@ -1278,7 +1278,7 @@ static int update_snapshot_refcount(BlockDriverState *bs, @@ -1278,7 +1278,7 @@ static int update_snapshot_refcount(BlockDriverState *bs,
1278 l1_table = s->l1_table; 1278 l1_table = s->l1_table;
1279 l1_allocated = 0; 1279 l1_allocated = 0;
1280 } 1280 }
1281 - 1281 +
1282 l2_size = s->l2_size * sizeof(uint64_t); 1282 l2_size = s->l2_size * sizeof(uint64_t);
1283 l2_table = qemu_malloc(l2_size); 1283 l2_table = qemu_malloc(l2_size);
1284 if (!l2_table) 1284 if (!l2_table)
@@ -1298,13 +1298,13 @@ static int update_snapshot_refcount(BlockDriverState *bs, @@ -1298,13 +1298,13 @@ static int update_snapshot_refcount(BlockDriverState *bs,
1298 old_offset = offset; 1298 old_offset = offset;
1299 offset &= ~QCOW_OFLAG_COPIED; 1299 offset &= ~QCOW_OFLAG_COPIED;
1300 if (offset & QCOW_OFLAG_COMPRESSED) { 1300 if (offset & QCOW_OFLAG_COMPRESSED) {
1301 - nb_csectors = ((offset >> s->csize_shift) & 1301 + nb_csectors = ((offset >> s->csize_shift) &
1302 s->csize_mask) + 1; 1302 s->csize_mask) + 1;
1303 if (addend != 0) 1303 if (addend != 0)
1304 update_refcount(bs, (offset & s->cluster_offset_mask) & ~511, 1304 update_refcount(bs, (offset & s->cluster_offset_mask) & ~511,
1305 nb_csectors * 512, addend); 1305 nb_csectors * 512, addend);
1306 /* compressed clusters are never modified */ 1306 /* compressed clusters are never modified */
1307 - refcount = 2; 1307 + refcount = 2;
1308 } else { 1308 } else {
1309 if (addend != 0) { 1309 if (addend != 0) {
1310 refcount = update_cluster_refcount(bs, offset >> s->cluster_bits, addend); 1310 refcount = update_cluster_refcount(bs, offset >> s->cluster_bits, addend);
@@ -1323,7 +1323,7 @@ static int update_snapshot_refcount(BlockDriverState *bs, @@ -1323,7 +1323,7 @@ static int update_snapshot_refcount(BlockDriverState *bs,
1323 } 1323 }
1324 } 1324 }
1325 if (l2_modified) { 1325 if (l2_modified) {
1326 - if (bdrv_pwrite(s->hd, 1326 + if (bdrv_pwrite(s->hd,
1327 l2_offset, l2_table, l2_size) != l2_size) 1327 l2_offset, l2_table, l2_size) != l2_size)
1328 goto fail; 1328 goto fail;
1329 } 1329 }
@@ -1345,7 +1345,7 @@ static int update_snapshot_refcount(BlockDriverState *bs, @@ -1345,7 +1345,7 @@ static int update_snapshot_refcount(BlockDriverState *bs,
1345 if (l1_modified) { 1345 if (l1_modified) {
1346 for(i = 0; i < l1_size; i++) 1346 for(i = 0; i < l1_size; i++)
1347 cpu_to_be64s(&l1_table[i]); 1347 cpu_to_be64s(&l1_table[i]);
1348 - if (bdrv_pwrite(s->hd, l1_table_offset, l1_table, 1348 + if (bdrv_pwrite(s->hd, l1_table_offset, l1_table,
1349 l1_size2) != l1_size2) 1349 l1_size2) != l1_size2)
1350 goto fail; 1350 goto fail;
1351 for(i = 0; i < l1_size; i++) 1351 for(i = 0; i < l1_size; i++)
@@ -1455,7 +1455,7 @@ static int qcow_write_snapshots(BlockDriverState *bs) @@ -1455,7 +1455,7 @@ static int qcow_write_snapshots(BlockDriverState *bs)
1455 1455
1456 snapshots_offset = alloc_clusters(bs, snapshots_size); 1456 snapshots_offset = alloc_clusters(bs, snapshots_size);
1457 offset = snapshots_offset; 1457 offset = snapshots_offset;
1458 - 1458 +
1459 for(i = 0; i < s->nb_snapshots; i++) { 1459 for(i = 0; i < s->nb_snapshots; i++) {
1460 sn = s->snapshots + i; 1460 sn = s->snapshots + i;
1461 memset(&h, 0, sizeof(h)); 1461 memset(&h, 0, sizeof(h));
@@ -1465,7 +1465,7 @@ static int qcow_write_snapshots(BlockDriverState *bs) @@ -1465,7 +1465,7 @@ static int qcow_write_snapshots(BlockDriverState *bs)
1465 h.date_sec = cpu_to_be32(sn->date_sec); 1465 h.date_sec = cpu_to_be32(sn->date_sec);
1466 h.date_nsec = cpu_to_be32(sn->date_nsec); 1466 h.date_nsec = cpu_to_be32(sn->date_nsec);
1467 h.vm_clock_nsec = cpu_to_be64(sn->vm_clock_nsec); 1467 h.vm_clock_nsec = cpu_to_be64(sn->vm_clock_nsec);
1468 - 1468 +
1469 id_str_size = strlen(sn->id_str); 1469 id_str_size = strlen(sn->id_str);
1470 name_size = strlen(sn->name); 1470 name_size = strlen(sn->name);
1471 h.id_str_size = cpu_to_be16(id_str_size); 1471 h.id_str_size = cpu_to_be16(id_str_size);
@@ -1533,7 +1533,7 @@ static int find_snapshot_by_id_or_name(BlockDriverState *bs, const char *name) @@ -1533,7 +1533,7 @@ static int find_snapshot_by_id_or_name(BlockDriverState *bs, const char *name)
1533 { 1533 {
1534 BDRVQcowState *s = bs->opaque; 1534 BDRVQcowState *s = bs->opaque;
1535 int i, ret; 1535 int i, ret;
1536 - 1536 +
1537 ret = find_snapshot_by_id(bs, name); 1537 ret = find_snapshot_by_id(bs, name);
1538 if (ret >= 0) 1538 if (ret >= 0)
1539 return ret; 1539 return ret;
@@ -1545,14 +1545,14 @@ static int find_snapshot_by_id_or_name(BlockDriverState *bs, const char *name) @@ -1545,14 +1545,14 @@ static int find_snapshot_by_id_or_name(BlockDriverState *bs, const char *name)
1545 } 1545 }
1546 1546
1547 /* if no id is provided, a new one is constructed */ 1547 /* if no id is provided, a new one is constructed */
1548 -static int qcow_snapshot_create(BlockDriverState *bs, 1548 +static int qcow_snapshot_create(BlockDriverState *bs,
1549 QEMUSnapshotInfo *sn_info) 1549 QEMUSnapshotInfo *sn_info)
1550 { 1550 {
1551 BDRVQcowState *s = bs->opaque; 1551 BDRVQcowState *s = bs->opaque;
1552 QCowSnapshot *snapshots1, sn1, *sn = &sn1; 1552 QCowSnapshot *snapshots1, sn1, *sn = &sn1;
1553 int i, ret; 1553 int i, ret;
1554 uint64_t *l1_table = NULL; 1554 uint64_t *l1_table = NULL;
1555 - 1555 +
1556 memset(sn, 0, sizeof(*sn)); 1556 memset(sn, 0, sizeof(*sn));
1557 1557
1558 if (sn_info->id_str[0] == '\0') { 1558 if (sn_info->id_str[0] == '\0') {
@@ -1590,7 +1590,7 @@ static int qcow_snapshot_create(BlockDriverState *bs, @@ -1590,7 +1590,7 @@ static int qcow_snapshot_create(BlockDriverState *bs,
1590 l1_table[i] = cpu_to_be64(s->l1_table[i]); 1590 l1_table[i] = cpu_to_be64(s->l1_table[i]);
1591 } 1591 }
1592 if (bdrv_pwrite(s->hd, sn->l1_table_offset, 1592 if (bdrv_pwrite(s->hd, sn->l1_table_offset,
1593 - l1_table, s->l1_size * sizeof(uint64_t)) != 1593 + l1_table, s->l1_size * sizeof(uint64_t)) !=
1594 (s->l1_size * sizeof(uint64_t))) 1594 (s->l1_size * sizeof(uint64_t)))
1595 goto fail; 1595 goto fail;
1596 qemu_free(l1_table); 1596 qemu_free(l1_table);
@@ -1616,7 +1616,7 @@ static int qcow_snapshot_create(BlockDriverState *bs, @@ -1616,7 +1616,7 @@ static int qcow_snapshot_create(BlockDriverState *bs,
1616 } 1616 }
1617 1617
1618 /* copy the snapshot 'snapshot_name' into the current disk image */ 1618 /* copy the snapshot 'snapshot_name' into the current disk image */
1619 -static int qcow_snapshot_goto(BlockDriverState *bs, 1619 +static int qcow_snapshot_goto(BlockDriverState *bs,
1620 const char *snapshot_id) 1620 const char *snapshot_id)
1621 { 1621 {
1622 BDRVQcowState *s = bs->opaque; 1622 BDRVQcowState *s = bs->opaque;
@@ -1637,7 +1637,7 @@ static int qcow_snapshot_goto(BlockDriverState *bs, @@ -1637,7 +1637,7 @@ static int qcow_snapshot_goto(BlockDriverState *bs,
1637 s->l1_size = sn->l1_size; 1637 s->l1_size = sn->l1_size;
1638 l1_size2 = s->l1_size * sizeof(uint64_t); 1638 l1_size2 = s->l1_size * sizeof(uint64_t);
1639 /* copy the snapshot l1 table to the current l1 table */ 1639 /* copy the snapshot l1 table to the current l1 table */
1640 - if (bdrv_pread(s->hd, sn->l1_table_offset, 1640 + if (bdrv_pread(s->hd, sn->l1_table_offset,
1641 s->l1_table, l1_size2) != l1_size2) 1641 s->l1_table, l1_size2) != l1_size2)
1642 goto fail; 1642 goto fail;
1643 if (bdrv_pwrite(s->hd, s->l1_table_offset, 1643 if (bdrv_pwrite(s->hd, s->l1_table_offset,
@@ -1663,7 +1663,7 @@ static int qcow_snapshot_delete(BlockDriverState *bs, const char *snapshot_id) @@ -1663,7 +1663,7 @@ static int qcow_snapshot_delete(BlockDriverState *bs, const char *snapshot_id)
1663 BDRVQcowState *s = bs->opaque; 1663 BDRVQcowState *s = bs->opaque;
1664 QCowSnapshot *sn; 1664 QCowSnapshot *sn;
1665 int snapshot_index, ret; 1665 int snapshot_index, ret;
1666 - 1666 +
1667 snapshot_index = find_snapshot_by_id_or_name(bs, snapshot_id); 1667 snapshot_index = find_snapshot_by_id_or_name(bs, snapshot_id);
1668 if (snapshot_index < 0) 1668 if (snapshot_index < 0)
1669 return -ENOENT; 1669 return -ENOENT;
@@ -1693,7 +1693,7 @@ static int qcow_snapshot_delete(BlockDriverState *bs, const char *snapshot_id) @@ -1693,7 +1693,7 @@ static int qcow_snapshot_delete(BlockDriverState *bs, const char *snapshot_id)
1693 return 0; 1693 return 0;
1694 } 1694 }
1695 1695
1696 -static int qcow_snapshot_list(BlockDriverState *bs, 1696 +static int qcow_snapshot_list(BlockDriverState *bs,
1697 QEMUSnapshotInfo **psn_tab) 1697 QEMUSnapshotInfo **psn_tab)
1698 { 1698 {
1699 BDRVQcowState *s = bs->opaque; 1699 BDRVQcowState *s = bs->opaque;
@@ -1731,7 +1731,7 @@ static int refcount_init(BlockDriverState *bs) @@ -1731,7 +1731,7 @@ static int refcount_init(BlockDriverState *bs)
1731 { 1731 {
1732 BDRVQcowState *s = bs->opaque; 1732 BDRVQcowState *s = bs->opaque;
1733 int ret, refcount_table_size2, i; 1733 int ret, refcount_table_size2, i;
1734 - 1734 +
1735 s->refcount_block_cache = qemu_malloc(s->cluster_size); 1735 s->refcount_block_cache = qemu_malloc(s->cluster_size);
1736 if (!s->refcount_block_cache) 1736 if (!s->refcount_block_cache)
1737 goto fail; 1737 goto fail;
@@ -1760,12 +1760,12 @@ static void refcount_close(BlockDriverState *bs) @@ -1760,12 +1760,12 @@ static void refcount_close(BlockDriverState *bs)
1760 } 1760 }
1761 1761
1762 1762
1763 -static int load_refcount_block(BlockDriverState *bs, 1763 +static int load_refcount_block(BlockDriverState *bs,
1764 int64_t refcount_block_offset) 1764 int64_t refcount_block_offset)
1765 { 1765 {
1766 BDRVQcowState *s = bs->opaque; 1766 BDRVQcowState *s = bs->opaque;
1767 int ret; 1767 int ret;
1768 - ret = bdrv_pread(s->hd, refcount_block_offset, s->refcount_block_cache, 1768 + ret = bdrv_pread(s->hd, refcount_block_offset, s->refcount_block_cache,
1769 s->cluster_size); 1769 s->cluster_size);
1770 if (ret != s->cluster_size) 1770 if (ret != s->cluster_size)
1771 return -EIO; 1771 return -EIO;
@@ -1790,7 +1790,7 @@ static int get_refcount(BlockDriverState *bs, int64_t cluster_index) @@ -1790,7 +1790,7 @@ static int get_refcount(BlockDriverState *bs, int64_t cluster_index)
1790 if (load_refcount_block(bs, refcount_block_offset) < 0) 1790 if (load_refcount_block(bs, refcount_block_offset) < 0)
1791 return 1; 1791 return 1;
1792 } 1792 }
1793 - block_index = cluster_index & 1793 + block_index = cluster_index &
1794 ((1 << (s->cluster_bits - REFCOUNT_SHIFT)) - 1); 1794 ((1 << (s->cluster_bits - REFCOUNT_SHIFT)) - 1);
1795 return be16_to_cpu(s->refcount_block_cache[block_index]); 1795 return be16_to_cpu(s->refcount_block_cache[block_index]);
1796 } 1796 }
@@ -1812,7 +1812,7 @@ static int64_t alloc_clusters_noref(BlockDriverState *bs, int64_t size) @@ -1812,7 +1812,7 @@ static int64_t alloc_clusters_noref(BlockDriverState *bs, int64_t size)
1812 } 1812 }
1813 #ifdef DEBUG_ALLOC2 1813 #ifdef DEBUG_ALLOC2
1814 printf("alloc_clusters: size=%lld -> %lld\n", 1814 printf("alloc_clusters: size=%lld -> %lld\n",
1815 - size, 1815 + size,
1816 (s->free_cluster_index - nb_clusters) << s->cluster_bits); 1816 (s->free_cluster_index - nb_clusters) << s->cluster_bits);
1817 #endif 1817 #endif
1818 return (s->free_cluster_index - nb_clusters) << s->cluster_bits; 1818 return (s->free_cluster_index - nb_clusters) << s->cluster_bits;
@@ -1839,13 +1839,13 @@ static int64_t alloc_bytes(BlockDriverState *bs, int size) @@ -1839,13 +1839,13 @@ static int64_t alloc_bytes(BlockDriverState *bs, int size)
1839 BDRVQcowState *s = bs->opaque; 1839 BDRVQcowState *s = bs->opaque;
1840 int64_t offset, cluster_offset; 1840 int64_t offset, cluster_offset;
1841 int free_in_cluster; 1841 int free_in_cluster;
1842 - 1842 +
1843 assert(size > 0 && size <= s->cluster_size); 1843 assert(size > 0 && size <= s->cluster_size);
1844 if (s->free_byte_offset == 0) { 1844 if (s->free_byte_offset == 0) {
1845 s->free_byte_offset = alloc_clusters(bs, s->cluster_size); 1845 s->free_byte_offset = alloc_clusters(bs, s->cluster_size);
1846 } 1846 }
1847 redo: 1847 redo:
1848 - free_in_cluster = s->cluster_size - 1848 + free_in_cluster = s->cluster_size -
1849 (s->free_byte_offset & (s->cluster_size - 1)); 1849 (s->free_byte_offset & (s->cluster_size - 1));
1850 if (size <= free_in_cluster) { 1850 if (size <= free_in_cluster) {
1851 /* enough space in current cluster */ 1851 /* enough space in current cluster */
@@ -1872,7 +1872,7 @@ static int64_t alloc_bytes(BlockDriverState *bs, int size) @@ -1872,7 +1872,7 @@ static int64_t alloc_bytes(BlockDriverState *bs, int size)
1872 return offset; 1872 return offset;
1873 } 1873 }
1874 1874
1875 -static void free_clusters(BlockDriverState *bs, 1875 +static void free_clusters(BlockDriverState *bs,
1876 int64_t offset, int64_t size) 1876 int64_t offset, int64_t size)
1877 { 1877 {
1878 update_refcount(bs, offset, size, -1); 1878 update_refcount(bs, offset, size, -1);
@@ -1912,14 +1912,14 @@ static int grow_refcount_table(BlockDriverState *bs, int min_size) @@ -1912,14 +1912,14 @@ static int grow_refcount_table(BlockDriverState *bs, int min_size)
1912 new_table = qemu_mallocz(new_table_size2); 1912 new_table = qemu_mallocz(new_table_size2);
1913 if (!new_table) 1913 if (!new_table)
1914 return -ENOMEM; 1914 return -ENOMEM;
1915 - memcpy(new_table, s->refcount_table, 1915 + memcpy(new_table, s->refcount_table,
1916 s->refcount_table_size * sizeof(uint64_t)); 1916 s->refcount_table_size * sizeof(uint64_t));
1917 for(i = 0; i < s->refcount_table_size; i++) 1917 for(i = 0; i < s->refcount_table_size; i++)
1918 cpu_to_be64s(&new_table[i]); 1918 cpu_to_be64s(&new_table[i]);
1919 /* Note: we cannot update the refcount now to avoid recursion */ 1919 /* Note: we cannot update the refcount now to avoid recursion */
1920 table_offset = alloc_clusters_noref(bs, new_table_size2); 1920 table_offset = alloc_clusters_noref(bs, new_table_size2);
1921 ret = bdrv_pwrite(s->hd, table_offset, new_table, new_table_size2); 1921 ret = bdrv_pwrite(s->hd, table_offset, new_table, new_table_size2);
1922 - if (ret != new_table_size2) 1922 + if (ret != new_table_size2)
1923 goto fail; 1923 goto fail;
1924 for(i = 0; i < s->refcount_table_size; i++) 1924 for(i = 0; i < s->refcount_table_size; i++)
1925 be64_to_cpus(&new_table[i]); 1925 be64_to_cpus(&new_table[i]);
@@ -1950,7 +1950,7 @@ static int grow_refcount_table(BlockDriverState *bs, int min_size) @@ -1950,7 +1950,7 @@ static int grow_refcount_table(BlockDriverState *bs, int min_size)
1950 1950
1951 /* addend must be 1 or -1 */ 1951 /* addend must be 1 or -1 */
1952 /* XXX: cache several refcount block clusters ? */ 1952 /* XXX: cache several refcount block clusters ? */
1953 -static int update_cluster_refcount(BlockDriverState *bs, 1953 +static int update_cluster_refcount(BlockDriverState *bs,
1954 int64_t cluster_index, 1954 int64_t cluster_index,
1955 int addend) 1955 int addend)
1956 { 1956 {
@@ -1980,8 +1980,8 @@ static int update_cluster_refcount(BlockDriverState *bs, @@ -1980,8 +1980,8 @@ static int update_cluster_refcount(BlockDriverState *bs,
1980 return -EINVAL; 1980 return -EINVAL;
1981 s->refcount_table[refcount_table_index] = offset; 1981 s->refcount_table[refcount_table_index] = offset;
1982 data64 = cpu_to_be64(offset); 1982 data64 = cpu_to_be64(offset);
1983 - ret = bdrv_pwrite(s->hd, s->refcount_table_offset +  
1984 - refcount_table_index * sizeof(uint64_t), 1983 + ret = bdrv_pwrite(s->hd, s->refcount_table_offset +
  1984 + refcount_table_index * sizeof(uint64_t),
1985 &data64, sizeof(data64)); 1985 &data64, sizeof(data64));
1986 if (ret != sizeof(data64)) 1986 if (ret != sizeof(data64))
1987 return -EINVAL; 1987 return -EINVAL;
@@ -1996,7 +1996,7 @@ static int update_cluster_refcount(BlockDriverState *bs, @@ -1996,7 +1996,7 @@ static int update_cluster_refcount(BlockDriverState *bs,
1996 } 1996 }
1997 } 1997 }
1998 /* we can update the count and save it */ 1998 /* we can update the count and save it */
1999 - block_index = cluster_index & 1999 + block_index = cluster_index &
2000 ((1 << (s->cluster_bits - REFCOUNT_SHIFT)) - 1); 2000 ((1 << (s->cluster_bits - REFCOUNT_SHIFT)) - 1);
2001 refcount = be16_to_cpu(s->refcount_block_cache[block_index]); 2001 refcount = be16_to_cpu(s->refcount_block_cache[block_index]);
2002 refcount += addend; 2002 refcount += addend;
@@ -2006,50 +2006,50 @@ static int update_cluster_refcount(BlockDriverState *bs, @@ -2006,50 +2006,50 @@ static int update_cluster_refcount(BlockDriverState *bs,
2006 s->free_cluster_index = cluster_index; 2006 s->free_cluster_index = cluster_index;
2007 } 2007 }
2008 s->refcount_block_cache[block_index] = cpu_to_be16(refcount); 2008 s->refcount_block_cache[block_index] = cpu_to_be16(refcount);
2009 - if (bdrv_pwrite(s->hd,  
2010 - refcount_block_offset + (block_index << REFCOUNT_SHIFT), 2009 + if (bdrv_pwrite(s->hd,
  2010 + refcount_block_offset + (block_index << REFCOUNT_SHIFT),
2011 &s->refcount_block_cache[block_index], 2) != 2) 2011 &s->refcount_block_cache[block_index], 2) != 2)
2012 return -EIO; 2012 return -EIO;
2013 return refcount; 2013 return refcount;
2014 } 2014 }
2015 2015
2016 -static void update_refcount(BlockDriverState *bs,  
2017 - int64_t offset, int64_t length, 2016 +static void update_refcount(BlockDriverState *bs,
  2017 + int64_t offset, int64_t length,
2018 int addend) 2018 int addend)
2019 { 2019 {
2020 BDRVQcowState *s = bs->opaque; 2020 BDRVQcowState *s = bs->opaque;
2021 int64_t start, last, cluster_offset; 2021 int64_t start, last, cluster_offset;
2022 2022
2023 #ifdef DEBUG_ALLOC2 2023 #ifdef DEBUG_ALLOC2
2024 - printf("update_refcount: offset=%lld size=%lld addend=%d\n", 2024 + printf("update_refcount: offset=%lld size=%lld addend=%d\n",
2025 offset, length, addend); 2025 offset, length, addend);
2026 #endif 2026 #endif
2027 if (length <= 0) 2027 if (length <= 0)
2028 return; 2028 return;
2029 start = offset & ~(s->cluster_size - 1); 2029 start = offset & ~(s->cluster_size - 1);
2030 last = (offset + length - 1) & ~(s->cluster_size - 1); 2030 last = (offset + length - 1) & ~(s->cluster_size - 1);
2031 - for(cluster_offset = start; cluster_offset <= last; 2031 + for(cluster_offset = start; cluster_offset <= last;
2032 cluster_offset += s->cluster_size) { 2032 cluster_offset += s->cluster_size) {
2033 update_cluster_refcount(bs, cluster_offset >> s->cluster_bits, addend); 2033 update_cluster_refcount(bs, cluster_offset >> s->cluster_bits, addend);
2034 } 2034 }
2035 } 2035 }
2036 2036
2037 #ifdef DEBUG_ALLOC 2037 #ifdef DEBUG_ALLOC
2038 -static void inc_refcounts(BlockDriverState *bs,  
2039 - uint16_t *refcount_table, 2038 +static void inc_refcounts(BlockDriverState *bs,
  2039 + uint16_t *refcount_table,
2040 int refcount_table_size, 2040 int refcount_table_size,
2041 int64_t offset, int64_t size) 2041 int64_t offset, int64_t size)
2042 { 2042 {
2043 BDRVQcowState *s = bs->opaque; 2043 BDRVQcowState *s = bs->opaque;
2044 int64_t start, last, cluster_offset; 2044 int64_t start, last, cluster_offset;
2045 int k; 2045 int k;
2046 - 2046 +
2047 if (size <= 0) 2047 if (size <= 0)
2048 return; 2048 return;
2049 2049
2050 start = offset & ~(s->cluster_size - 1); 2050 start = offset & ~(s->cluster_size - 1);
2051 last = (offset + size - 1) & ~(s->cluster_size - 1); 2051 last = (offset + size - 1) & ~(s->cluster_size - 1);
2052 - for(cluster_offset = start; cluster_offset <= last; 2052 + for(cluster_offset = start; cluster_offset <= last;
2053 cluster_offset += s->cluster_size) { 2053 cluster_offset += s->cluster_size) {
2054 k = cluster_offset >> s->cluster_bits; 2054 k = cluster_offset >> s->cluster_bits;
2055 if (k < 0 || k >= refcount_table_size) { 2055 if (k < 0 || k >= refcount_table_size) {
@@ -2062,8 +2062,8 @@ static void inc_refcounts(BlockDriverState *bs, @@ -2062,8 +2062,8 @@ static void inc_refcounts(BlockDriverState *bs,
2062 } 2062 }
2063 } 2063 }
2064 2064
2065 -static int check_refcounts_l1(BlockDriverState *bs,  
2066 - uint16_t *refcount_table, 2065 +static int check_refcounts_l1(BlockDriverState *bs,
  2066 + uint16_t *refcount_table,
2067 int refcount_table_size, 2067 int refcount_table_size,
2068 int64_t l1_table_offset, int l1_size, 2068 int64_t l1_table_offset, int l1_size,
2069 int check_copied) 2069 int check_copied)
@@ -2081,12 +2081,12 @@ static int check_refcounts_l1(BlockDriverState *bs, @@ -2081,12 +2081,12 @@ static int check_refcounts_l1(BlockDriverState *bs,
2081 l1_table = qemu_malloc(l1_size2); 2081 l1_table = qemu_malloc(l1_size2);
2082 if (!l1_table) 2082 if (!l1_table)
2083 goto fail; 2083 goto fail;
2084 - if (bdrv_pread(s->hd, l1_table_offset, 2084 + if (bdrv_pread(s->hd, l1_table_offset,
2085 l1_table, l1_size2) != l1_size2) 2085 l1_table, l1_size2) != l1_size2)
2086 goto fail; 2086 goto fail;
2087 for(i = 0;i < l1_size; i++) 2087 for(i = 0;i < l1_size; i++)
2088 be64_to_cpus(&l1_table[i]); 2088 be64_to_cpus(&l1_table[i]);
2089 - 2089 +
2090 l2_size = s->l2_size * sizeof(uint64_t); 2090 l2_size = s->l2_size * sizeof(uint64_t);
2091 l2_table = qemu_malloc(l2_size); 2091 l2_table = qemu_malloc(l2_size);
2092 if (!l2_table) 2092 if (!l2_table)
@@ -2113,10 +2113,10 @@ static int check_refcounts_l1(BlockDriverState *bs, @@ -2113,10 +2113,10 @@ static int check_refcounts_l1(BlockDriverState *bs,
2113 offset >> s->cluster_bits); 2113 offset >> s->cluster_bits);
2114 offset &= ~QCOW_OFLAG_COPIED; 2114 offset &= ~QCOW_OFLAG_COPIED;
2115 } 2115 }
2116 - nb_csectors = ((offset >> s->csize_shift) & 2116 + nb_csectors = ((offset >> s->csize_shift) &
2117 s->csize_mask) + 1; 2117 s->csize_mask) + 1;
2118 offset &= s->cluster_offset_mask; 2118 offset &= s->cluster_offset_mask;
2119 - inc_refcounts(bs, refcount_table, 2119 + inc_refcounts(bs, refcount_table,
2120 refcount_table_size, 2120 refcount_table_size,
2121 offset & ~511, nb_csectors * 512); 2121 offset & ~511, nb_csectors * 512);
2122 } else { 2122 } else {
@@ -2128,13 +2128,13 @@ static int check_refcounts_l1(BlockDriverState *bs, @@ -2128,13 +2128,13 @@ static int check_refcounts_l1(BlockDriverState *bs,
2128 } 2128 }
2129 } 2129 }
2130 offset &= ~QCOW_OFLAG_COPIED; 2130 offset &= ~QCOW_OFLAG_COPIED;
2131 - inc_refcounts(bs, refcount_table, 2131 + inc_refcounts(bs, refcount_table,
2132 refcount_table_size, 2132 refcount_table_size,
2133 offset, s->cluster_size); 2133 offset, s->cluster_size);
2134 } 2134 }
2135 } 2135 }
2136 } 2136 }
2137 - inc_refcounts(bs, refcount_table, 2137 + inc_refcounts(bs, refcount_table,
2138 refcount_table_size, 2138 refcount_table_size,
2139 l2_offset, 2139 l2_offset,
2140 s->cluster_size); 2140 s->cluster_size);
@@ -2165,7 +2165,7 @@ static void check_refcounts(BlockDriverState *bs) @@ -2165,7 +2165,7 @@ static void check_refcounts(BlockDriverState *bs)
2165 /* header */ 2165 /* header */
2166 inc_refcounts(bs, refcount_table, nb_clusters, 2166 inc_refcounts(bs, refcount_table, nb_clusters,
2167 0, s->cluster_size); 2167 0, s->cluster_size);
2168 - 2168 +
2169 check_refcounts_l1(bs, refcount_table, nb_clusters, 2169 check_refcounts_l1(bs, refcount_table, nb_clusters,
2170 s->l1_table_offset, s->l1_size, 1); 2170 s->l1_table_offset, s->l1_size, 1);
2171 2171
@@ -2180,7 +2180,7 @@ static void check_refcounts(BlockDriverState *bs) @@ -2180,7 +2180,7 @@ static void check_refcounts(BlockDriverState *bs)
2180 2180
2181 /* refcount data */ 2181 /* refcount data */
2182 inc_refcounts(bs, refcount_table, nb_clusters, 2182 inc_refcounts(bs, refcount_table, nb_clusters,
2183 - s->refcount_table_offset, 2183 + s->refcount_table_offset,
2184 s->refcount_table_size * sizeof(uint64_t)); 2184 s->refcount_table_size * sizeof(uint64_t));
2185 for(i = 0; i < s->refcount_table_size; i++) { 2185 for(i = 0; i < s->refcount_table_size; i++) {
2186 int64_t offset; 2186 int64_t offset;
block-raw.c
1 /* 1 /*
2 * Block driver for RAW files 2 * Block driver for RAW files
3 - * 3 + *
4 * Copyright (c) 2006 Fabrice Bellard 4 * Copyright (c) 2006 Fabrice Bellard
5 - * 5 + *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy 6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal 7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights 8 * in the Software without restriction, including without limitation the rights
@@ -137,12 +137,12 @@ static int raw_open(BlockDriverState *bs, const char *filename, int flags) @@ -137,12 +137,12 @@ static int raw_open(BlockDriverState *bs, const char *filename, int flags)
137 #endif 137 #endif
138 */ 138 */
139 139
140 -static int raw_pread(BlockDriverState *bs, int64_t offset, 140 +static int raw_pread(BlockDriverState *bs, int64_t offset,
141 uint8_t *buf, int count) 141 uint8_t *buf, int count)
142 { 142 {
143 BDRVRawState *s = bs->opaque; 143 BDRVRawState *s = bs->opaque;
144 int ret; 144 int ret;
145 - 145 +
146 ret = fd_open(bs); 146 ret = fd_open(bs);
147 if (ret < 0) 147 if (ret < 0)
148 return ret; 148 return ret;
@@ -189,12 +189,12 @@ label__raw_read__success: @@ -189,12 +189,12 @@ label__raw_read__success:
189 return ret; 189 return ret;
190 } 190 }
191 191
192 -static int raw_pwrite(BlockDriverState *bs, int64_t offset, 192 +static int raw_pwrite(BlockDriverState *bs, int64_t offset,
193 const uint8_t *buf, int count) 193 const uint8_t *buf, int count)
194 { 194 {
195 BDRVRawState *s = bs->opaque; 195 BDRVRawState *s = bs->opaque;
196 int ret; 196 int ret;
197 - 197 +
198 ret = fd_open(bs); 198 ret = fd_open(bs);
199 if (ret < 0) 199 if (ret < 0)
200 return ret; 200 return ret;
@@ -259,7 +259,7 @@ void qemu_aio_init(void) @@ -259,7 +259,7 @@ void qemu_aio_init(void)
259 struct sigaction act; 259 struct sigaction act;
260 260
261 aio_initialized = 1; 261 aio_initialized = 1;
262 - 262 +
263 sigfillset(&act.sa_mask); 263 sigfillset(&act.sa_mask);
264 act.sa_flags = 0; /* do not restart syscalls to interrupt select() */ 264 act.sa_flags = 0; /* do not restart syscalls to interrupt select() */
265 act.sa_handler = aio_signal_handler; 265 act.sa_handler = aio_signal_handler;
@@ -401,7 +401,7 @@ static BlockDriverAIOCB *raw_aio_read(BlockDriverState *bs, @@ -401,7 +401,7 @@ static BlockDriverAIOCB *raw_aio_read(BlockDriverState *bs,
401 if (aio_read(&acb->aiocb) < 0) { 401 if (aio_read(&acb->aiocb) < 0) {
402 qemu_aio_release(acb); 402 qemu_aio_release(acb);
403 return NULL; 403 return NULL;
404 - } 404 + }
405 return &acb->common; 405 return &acb->common;
406 } 406 }
407 407
@@ -417,7 +417,7 @@ static BlockDriverAIOCB *raw_aio_write(BlockDriverState *bs, @@ -417,7 +417,7 @@ static BlockDriverAIOCB *raw_aio_write(BlockDriverState *bs,
417 if (aio_write(&acb->aiocb) < 0) { 417 if (aio_write(&acb->aiocb) < 0) {
418 qemu_aio_release(acb); 418 qemu_aio_release(acb);
419 return NULL; 419 return NULL;
420 - } 420 + }
421 return &acb->common; 421 return &acb->common;
422 } 422 }
423 423
@@ -522,7 +522,7 @@ static int raw_create(const char *filename, int64_t total_size, @@ -522,7 +522,7 @@ static int raw_create(const char *filename, int64_t total_size,
522 if (flags || backing_file) 522 if (flags || backing_file)
523 return -ENOTSUP; 523 return -ENOTSUP;
524 524
525 - fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 525 + fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY,
526 0644); 526 0644);
527 if (fd < 0) 527 if (fd < 0)
528 return -EIO; 528 return -EIO;
@@ -547,7 +547,7 @@ BlockDriver bdrv_raw = { @@ -547,7 +547,7 @@ BlockDriver bdrv_raw = {
547 raw_close, 547 raw_close,
548 raw_create, 548 raw_create,
549 raw_flush, 549 raw_flush,
550 - 550 +
551 .bdrv_aio_read = raw_aio_read, 551 .bdrv_aio_read = raw_aio_read,
552 .bdrv_aio_write = raw_aio_write, 552 .bdrv_aio_write = raw_aio_write,
553 .bdrv_aio_cancel = raw_aio_cancel, 553 .bdrv_aio_cancel = raw_aio_cancel,
@@ -568,7 +568,7 @@ static kern_return_t GetBSDPath( io_iterator_t mediaIterator, char *bsdPath, CFI @@ -568,7 +568,7 @@ static kern_return_t GetBSDPath( io_iterator_t mediaIterator, char *bsdPath, CFI
568 568
569 kern_return_t FindEjectableCDMedia( io_iterator_t *mediaIterator ) 569 kern_return_t FindEjectableCDMedia( io_iterator_t *mediaIterator )
570 { 570 {
571 - kern_return_t kernResult; 571 + kern_return_t kernResult;
572 mach_port_t masterPort; 572 mach_port_t masterPort;
573 CFMutableDictionaryRef classesToMatch; 573 CFMutableDictionaryRef classesToMatch;
574 574
@@ -576,8 +576,8 @@ kern_return_t FindEjectableCDMedia( io_iterator_t *mediaIterator ) @@ -576,8 +576,8 @@ kern_return_t FindEjectableCDMedia( io_iterator_t *mediaIterator )
576 if ( KERN_SUCCESS != kernResult ) { 576 if ( KERN_SUCCESS != kernResult ) {
577 printf( "IOMasterPort returned %d\n", kernResult ); 577 printf( "IOMasterPort returned %d\n", kernResult );
578 } 578 }
579 -  
580 - classesToMatch = IOServiceMatching( kIOCDMediaClass ); 579 +
  580 + classesToMatch = IOServiceMatching( kIOCDMediaClass );
581 if ( classesToMatch == NULL ) { 581 if ( classesToMatch == NULL ) {
582 printf( "IOServiceMatching returned a NULL dictionary.\n" ); 582 printf( "IOServiceMatching returned a NULL dictionary.\n" );
583 } else { 583 } else {
@@ -588,7 +588,7 @@ kern_return_t FindEjectableCDMedia( io_iterator_t *mediaIterator ) @@ -588,7 +588,7 @@ kern_return_t FindEjectableCDMedia( io_iterator_t *mediaIterator )
588 { 588 {
589 printf( "IOServiceGetMatchingServices returned %d\n", kernResult ); 589 printf( "IOServiceGetMatchingServices returned %d\n", kernResult );
590 } 590 }
591 - 591 +
592 return kernResult; 592 return kernResult;
593 } 593 }
594 594
@@ -614,7 +614,7 @@ kern_return_t GetBSDPath( io_iterator_t mediaIterator, char *bsdPath, CFIndex ma @@ -614,7 +614,7 @@ kern_return_t GetBSDPath( io_iterator_t mediaIterator, char *bsdPath, CFIndex ma
614 } 614 }
615 IOObjectRelease( nextMedia ); 615 IOObjectRelease( nextMedia );
616 } 616 }
617 - 617 +
618 return kernResult; 618 return kernResult;
619 } 619 }
620 620
@@ -631,10 +631,10 @@ static int hdev_open(BlockDriverState *bs, const char *filename, int flags) @@ -631,10 +631,10 @@ static int hdev_open(BlockDriverState *bs, const char *filename, int flags)
631 io_iterator_t mediaIterator; 631 io_iterator_t mediaIterator;
632 char bsdPath[ MAXPATHLEN ]; 632 char bsdPath[ MAXPATHLEN ];
633 int fd; 633 int fd;
634 - 634 +
635 kernResult = FindEjectableCDMedia( &mediaIterator ); 635 kernResult = FindEjectableCDMedia( &mediaIterator );
636 kernResult = GetBSDPath( mediaIterator, bsdPath, sizeof( bsdPath ) ); 636 kernResult = GetBSDPath( mediaIterator, bsdPath, sizeof( bsdPath ) );
637 - 637 +
638 if ( bsdPath[ 0 ] != '\0' ) { 638 if ( bsdPath[ 0 ] != '\0' ) {
639 strcat(bsdPath,"s0"); 639 strcat(bsdPath,"s0");
640 /* some CDs don't have a partition 0 */ 640 /* some CDs don't have a partition 0 */
@@ -646,7 +646,7 @@ static int hdev_open(BlockDriverState *bs, const char *filename, int flags) @@ -646,7 +646,7 @@ static int hdev_open(BlockDriverState *bs, const char *filename, int flags)
646 } 646 }
647 filename = bsdPath; 647 filename = bsdPath;
648 } 648 }
649 - 649 +
650 if ( mediaIterator ) 650 if ( mediaIterator )
651 IOObjectRelease( mediaIterator ); 651 IOObjectRelease( mediaIterator );
652 } 652 }
@@ -704,7 +704,7 @@ static int fd_open(BlockDriverState *bs) @@ -704,7 +704,7 @@ static int fd_open(BlockDriverState *bs)
704 if (s->type != FTYPE_FD) 704 if (s->type != FTYPE_FD)
705 return 0; 705 return 0;
706 last_media_present = (s->fd >= 0); 706 last_media_present = (s->fd >= 0);
707 - if (s->fd >= 0 && 707 + if (s->fd >= 0 &&
708 (qemu_get_clock(rt_clock) - s->fd_open_time) >= FD_OPEN_TIMEOUT) { 708 (qemu_get_clock(rt_clock) - s->fd_open_time) >= FD_OPEN_TIMEOUT) {
709 close(s->fd); 709 close(s->fd);
710 s->fd = -1; 710 s->fd = -1;
@@ -713,7 +713,7 @@ static int fd_open(BlockDriverState *bs) @@ -713,7 +713,7 @@ static int fd_open(BlockDriverState *bs)
713 #endif 713 #endif
714 } 714 }
715 if (s->fd < 0) { 715 if (s->fd < 0) {
716 - if (s->fd_got_error && 716 + if (s->fd_got_error &&
717 (qemu_get_clock(rt_clock) - s->fd_error_time) < FD_OPEN_TIMEOUT) { 717 (qemu_get_clock(rt_clock) - s->fd_error_time) < FD_OPEN_TIMEOUT) {
718 #ifdef DEBUG_FLOPPY 718 #ifdef DEBUG_FLOPPY
719 printf("No floppy (open delayed)\n"); 719 printf("No floppy (open delayed)\n");
@@ -883,7 +883,7 @@ BlockDriver bdrv_host_device = { @@ -883,7 +883,7 @@ BlockDriver bdrv_host_device = {
883 raw_close, 883 raw_close,
884 NULL, 884 NULL,
885 raw_flush, 885 raw_flush,
886 - 886 +
887 .bdrv_aio_read = raw_aio_read, 887 .bdrv_aio_read = raw_aio_read,
888 .bdrv_aio_write = raw_aio_write, 888 .bdrv_aio_write = raw_aio_write,
889 .bdrv_aio_cancel = raw_aio_cancel, 889 .bdrv_aio_cancel = raw_aio_cancel,
@@ -979,7 +979,7 @@ static int raw_open(BlockDriverState *bs, const char *filename, int flags) @@ -979,7 +979,7 @@ static int raw_open(BlockDriverState *bs, const char *filename, int flags)
979 #else 979 #else
980 overlapped = FILE_FLAG_OVERLAPPED; 980 overlapped = FILE_FLAG_OVERLAPPED;
981 #endif 981 #endif
982 - s->hfile = CreateFile(filename, access_flags, 982 + s->hfile = CreateFile(filename, access_flags,
983 FILE_SHARE_READ, NULL, 983 FILE_SHARE_READ, NULL,
984 create_flags, overlapped, NULL); 984 create_flags, overlapped, NULL);
985 if (s->hfile == INVALID_HANDLE_VALUE) { 985 if (s->hfile == INVALID_HANDLE_VALUE) {
@@ -992,14 +992,14 @@ static int raw_open(BlockDriverState *bs, const char *filename, int flags) @@ -992,14 +992,14 @@ static int raw_open(BlockDriverState *bs, const char *filename, int flags)
992 return 0; 992 return 0;
993 } 993 }
994 994
995 -static int raw_pread(BlockDriverState *bs, int64_t offset, 995 +static int raw_pread(BlockDriverState *bs, int64_t offset,
996 uint8_t *buf, int count) 996 uint8_t *buf, int count)
997 { 997 {
998 BDRVRawState *s = bs->opaque; 998 BDRVRawState *s = bs->opaque;
999 OVERLAPPED ov; 999 OVERLAPPED ov;
1000 DWORD ret_count; 1000 DWORD ret_count;
1001 int ret; 1001 int ret;
1002 - 1002 +
1003 memset(&ov, 0, sizeof(ov)); 1003 memset(&ov, 0, sizeof(ov));
1004 ov.Offset = offset; 1004 ov.Offset = offset;
1005 ov.OffsetHigh = offset >> 32; 1005 ov.OffsetHigh = offset >> 32;
@@ -1014,14 +1014,14 @@ static int raw_pread(BlockDriverState *bs, int64_t offset, @@ -1014,14 +1014,14 @@ static int raw_pread(BlockDriverState *bs, int64_t offset,
1014 return ret_count; 1014 return ret_count;
1015 } 1015 }
1016 1016
1017 -static int raw_pwrite(BlockDriverState *bs, int64_t offset, 1017 +static int raw_pwrite(BlockDriverState *bs, int64_t offset,
1018 const uint8_t *buf, int count) 1018 const uint8_t *buf, int count)
1019 { 1019 {
1020 BDRVRawState *s = bs->opaque; 1020 BDRVRawState *s = bs->opaque;
1021 OVERLAPPED ov; 1021 OVERLAPPED ov;
1022 DWORD ret_count; 1022 DWORD ret_count;
1023 int ret; 1023 int ret;
1024 - 1024 +
1025 memset(&ov, 0, sizeof(ov)); 1025 memset(&ov, 0, sizeof(ov));
1026 ov.Offset = offset; 1026 ov.Offset = offset;
1027 ov.OffsetHigh = offset >> 32; 1027 ov.OffsetHigh = offset >> 32;
@@ -1171,7 +1171,7 @@ static int64_t raw_getlength(BlockDriverState *bs) @@ -1171,7 +1171,7 @@ static int64_t raw_getlength(BlockDriverState *bs)
1171 { 1171 {
1172 BDRVRawState *s = bs->opaque; 1172 BDRVRawState *s = bs->opaque;
1173 LARGE_INTEGER l; 1173 LARGE_INTEGER l;
1174 - ULARGE_INTEGER available, total, total_free; 1174 + ULARGE_INTEGER available, total, total_free;
1175 DISK_GEOMETRY dg; 1175 DISK_GEOMETRY dg;
1176 DWORD count; 1176 DWORD count;
1177 BOOL status; 1177 BOOL status;
@@ -1209,7 +1209,7 @@ static int raw_create(const char *filename, int64_t total_size, @@ -1209,7 +1209,7 @@ static int raw_create(const char *filename, int64_t total_size,
1209 if (flags || backing_file) 1209 if (flags || backing_file)
1210 return -ENOTSUP; 1210 return -ENOTSUP;
1211 1211
1212 - fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 1212 + fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY,
1213 0644); 1213 0644);
1214 if (fd < 0) 1214 if (fd < 0)
1215 return -EIO; 1215 return -EIO;
@@ -1256,7 +1256,7 @@ BlockDriver bdrv_raw = { @@ -1256,7 +1256,7 @@ BlockDriver bdrv_raw = {
1256 raw_close, 1256 raw_close,
1257 raw_create, 1257 raw_create,
1258 raw_flush, 1258 raw_flush,
1259 - 1259 +
1260 #if 0 1260 #if 0
1261 .bdrv_aio_read = raw_aio_read, 1261 .bdrv_aio_read = raw_aio_read,
1262 .bdrv_aio_write = raw_aio_write, 1262 .bdrv_aio_write = raw_aio_write,
@@ -1335,7 +1335,7 @@ static int hdev_open(BlockDriverState *bs, const char *filename, int flags) @@ -1335,7 +1335,7 @@ static int hdev_open(BlockDriverState *bs, const char *filename, int flags)
1335 } 1335 }
1336 } 1336 }
1337 s->type = find_device_type(bs, filename); 1337 s->type = find_device_type(bs, filename);
1338 - 1338 +
1339 if ((flags & BDRV_O_ACCESS) == O_RDWR) { 1339 if ((flags & BDRV_O_ACCESS) == O_RDWR) {
1340 access_flags = GENERIC_READ | GENERIC_WRITE; 1340 access_flags = GENERIC_READ | GENERIC_WRITE;
1341 } else { 1341 } else {
@@ -1348,7 +1348,7 @@ static int hdev_open(BlockDriverState *bs, const char *filename, int flags) @@ -1348,7 +1348,7 @@ static int hdev_open(BlockDriverState *bs, const char *filename, int flags)
1348 #else 1348 #else
1349 overlapped = FILE_FLAG_OVERLAPPED; 1349 overlapped = FILE_FLAG_OVERLAPPED;
1350 #endif 1350 #endif
1351 - s->hfile = CreateFile(filename, access_flags, 1351 + s->hfile = CreateFile(filename, access_flags,
1352 FILE_SHARE_READ, NULL, 1352 FILE_SHARE_READ, NULL,
1353 create_flags, overlapped, NULL); 1353 create_flags, overlapped, NULL);
1354 if (s->hfile == INVALID_HANDLE_VALUE) { 1354 if (s->hfile == INVALID_HANDLE_VALUE) {
@@ -1382,10 +1382,10 @@ static int raw_eject(BlockDriverState *bs, int eject_flag) @@ -1382,10 +1382,10 @@ static int raw_eject(BlockDriverState *bs, int eject_flag)
1382 if (s->type == FTYPE_FILE) 1382 if (s->type == FTYPE_FILE)
1383 return -ENOTSUP; 1383 return -ENOTSUP;
1384 if (eject_flag) { 1384 if (eject_flag) {
1385 - DeviceIoControl(s->hfile, IOCTL_STORAGE_EJECT_MEDIA, 1385 + DeviceIoControl(s->hfile, IOCTL_STORAGE_EJECT_MEDIA,
1386 NULL, 0, NULL, 0, &lpBytesReturned, NULL); 1386 NULL, 0, NULL, 0, &lpBytesReturned, NULL);
1387 } else { 1387 } else {
1388 - DeviceIoControl(s->hfile, IOCTL_STORAGE_LOAD_MEDIA, 1388 + DeviceIoControl(s->hfile, IOCTL_STORAGE_LOAD_MEDIA,
1389 NULL, 0, NULL, 0, &lpBytesReturned, NULL); 1389 NULL, 0, NULL, 0, &lpBytesReturned, NULL);
1390 } 1390 }
1391 } 1391 }
@@ -1406,7 +1406,7 @@ BlockDriver bdrv_host_device = { @@ -1406,7 +1406,7 @@ BlockDriver bdrv_host_device = {
1406 raw_close, 1406 raw_close,
1407 NULL, 1407 NULL,
1408 raw_flush, 1408 raw_flush,
1409 - 1409 +
1410 #if 0 1410 #if 0
1411 .bdrv_aio_read = raw_aio_read, 1411 .bdrv_aio_read = raw_aio_read,
1412 .bdrv_aio_write = raw_aio_write, 1412 .bdrv_aio_write = raw_aio_write,
block-vmdk.c
1 /* 1 /*
2 * Block driver for the VMDK format 2 * Block driver for the VMDK format
3 - * 3 + *
4 * Copyright (c) 2004 Fabrice Bellard 4 * Copyright (c) 2004 Fabrice Bellard
5 * Copyright (c) 2005 Filip Navara 5 * Copyright (c) 2005 Filip Navara
6 - * 6 + *
7 * Permission is hereby granted, free of charge, to any person obtaining a copy 7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal 8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights 9 * in the Software without restriction, including without limitation the rights
@@ -110,16 +110,16 @@ static int vmdk_probe(const uint8_t *buf, int buf_size, const char *filename) @@ -110,16 +110,16 @@ static int vmdk_probe(const uint8_t *buf, int buf_size, const char *filename)
110 110
111 #define CHECK_CID 1 111 #define CHECK_CID 1
112 112
113 -#define SECTOR_SIZE 512 113 +#define SECTOR_SIZE 512
114 #define DESC_SIZE 20*SECTOR_SIZE // 20 sectors of 512 bytes each 114 #define DESC_SIZE 20*SECTOR_SIZE // 20 sectors of 512 bytes each
115 -#define HEADER_SIZE 512 // first sector of 512 bytes 115 +#define HEADER_SIZE 512 // first sector of 512 bytes
116 116
117 static uint32_t vmdk_read_cid(BlockDriverState *bs, int parent) 117 static uint32_t vmdk_read_cid(BlockDriverState *bs, int parent)
118 { 118 {
119 BDRVVmdkState *s = bs->opaque; 119 BDRVVmdkState *s = bs->opaque;
120 char desc[DESC_SIZE]; 120 char desc[DESC_SIZE];
121 uint32_t cid; 121 uint32_t cid;
122 - char *p_name, *cid_str; 122 + char *p_name, *cid_str;
123 size_t cid_str_size; 123 size_t cid_str_size;
124 124
125 /* the descriptor offset = 0x200 */ 125 /* the descriptor offset = 0x200 */
@@ -187,7 +187,7 @@ static int vmdk_snapshot_create(const char *filename, const char *backing_file) @@ -187,7 +187,7 @@ static int vmdk_snapshot_create(const char *filename, const char *backing_file)
187 { 187 {
188 int snp_fd, p_fd; 188 int snp_fd, p_fd;
189 uint32_t p_cid; 189 uint32_t p_cid;
190 - char *p_name, *gd_buf, *rgd_buf; 190 + char *p_name, *gd_buf, *rgd_buf;
191 const char *real_filename, *temp_str; 191 const char *real_filename, *temp_str;
192 VMDK4Header header; 192 VMDK4Header header;
193 uint32_t gde_entries, gd_size; 193 uint32_t gde_entries, gd_size;
@@ -271,7 +271,7 @@ static int vmdk_snapshot_create(const char *filename, const char *backing_file) @@ -271,7 +271,7 @@ static int vmdk_snapshot_create(const char *filename, const char *backing_file)
271 gt_size = (int64_t)header.num_gtes_per_gte * header.granularity * SECTOR_SIZE; 271 gt_size = (int64_t)header.num_gtes_per_gte * header.granularity * SECTOR_SIZE;
272 if (!gt_size) 272 if (!gt_size)
273 goto fail; 273 goto fail;
274 - gde_entries = (uint32_t)(capacity / gt_size); // number of gde/rgde 274 + gde_entries = (uint32_t)(capacity / gt_size); // number of gde/rgde
275 gd_size = gde_entries * sizeof(uint32_t); 275 gd_size = gde_entries * sizeof(uint32_t);
276 276
277 /* write RGD */ 277 /* write RGD */
@@ -308,7 +308,7 @@ static int vmdk_snapshot_create(const char *filename, const char *backing_file) @@ -308,7 +308,7 @@ static int vmdk_snapshot_create(const char *filename, const char *backing_file)
308 308
309 fail_gd: 309 fail_gd:
310 qemu_free(gd_buf); 310 qemu_free(gd_buf);
311 - fail_rgd: 311 + fail_rgd:
312 qemu_free(rgd_buf); 312 qemu_free(rgd_buf);
313 fail: 313 fail:
314 close(p_fd); 314 close(p_fd);
@@ -326,7 +326,7 @@ int parent_open = 0; @@ -326,7 +326,7 @@ int parent_open = 0;
326 static int vmdk_parent_open(BlockDriverState *bs, const char * filename) 326 static int vmdk_parent_open(BlockDriverState *bs, const char * filename)
327 { 327 {
328 BDRVVmdkState *s = bs->opaque; 328 BDRVVmdkState *s = bs->opaque;
329 - char *p_name; 329 + char *p_name;
330 char desc[DESC_SIZE]; 330 char desc[DESC_SIZE];
331 char parent_img_name[1024]; 331 char parent_img_name[1024];
332 332
@@ -341,7 +341,7 @@ static int vmdk_parent_open(BlockDriverState *bs, const char * filename) @@ -341,7 +341,7 @@ static int vmdk_parent_open(BlockDriverState *bs, const char * filename)
341 p_name += sizeof("parentFileNameHint") + 1; 341 p_name += sizeof("parentFileNameHint") + 1;
342 if ((end_name = strchr(p_name,'\"')) == 0) 342 if ((end_name = strchr(p_name,'\"')) == 0)
343 return -1; 343 return -1;
344 - 344 +
345 strncpy(s->hd->backing_file, p_name, end_name - p_name); 345 strncpy(s->hd->backing_file, p_name, end_name - p_name);
346 if (stat(s->hd->backing_file, &file_buf) != 0) { 346 if (stat(s->hd->backing_file, &file_buf) != 0) {
347 path_combine(parent_img_name, sizeof(parent_img_name), 347 path_combine(parent_img_name, sizeof(parent_img_name),
@@ -406,7 +406,7 @@ static int vmdk_open(BlockDriverState *bs, const char *filename, int flags) @@ -406,7 +406,7 @@ static int vmdk_open(BlockDriverState *bs, const char *filename, int flags)
406 s->l1_entry_sectors = s->l2_size * s->cluster_sectors; 406 s->l1_entry_sectors = s->l2_size * s->cluster_sectors;
407 if (s->l1_entry_sectors <= 0) 407 if (s->l1_entry_sectors <= 0)
408 goto fail; 408 goto fail;
409 - s->l1_size = (bs->total_sectors + s->l1_entry_sectors - 1) 409 + s->l1_size = (bs->total_sectors + s->l1_entry_sectors - 1)
410 / s->l1_entry_sectors; 410 / s->l1_entry_sectors;
411 s->l1_table_offset = le64_to_cpu(header.rgd_offset) << 9; 411 s->l1_table_offset = le64_to_cpu(header.rgd_offset) << 9;
412 s->l1_backup_table_offset = le64_to_cpu(header.gd_offset) << 9; 412 s->l1_backup_table_offset = le64_to_cpu(header.gd_offset) << 9;
@@ -552,7 +552,7 @@ static uint64_t get_cluster_offset(BlockDriverState *bs, VmdkMetaData *m_data, @@ -552,7 +552,7 @@ static uint64_t get_cluster_offset(BlockDriverState *bs, VmdkMetaData *m_data,
552 } 552 }
553 } 553 }
554 l2_table = s->l2_cache + (min_index * s->l2_size); 554 l2_table = s->l2_cache + (min_index * s->l2_size);
555 - if (bdrv_pread(s->hd, (int64_t)l2_offset * 512, l2_table, s->l2_size * sizeof(uint32_t)) != 555 + if (bdrv_pread(s->hd, (int64_t)l2_offset * 512, l2_table, s->l2_size * sizeof(uint32_t)) !=
556 s->l2_size * sizeof(uint32_t)) 556 s->l2_size * sizeof(uint32_t))
557 return 0; 557 return 0;
558 558
@@ -597,7 +597,7 @@ static uint64_t get_cluster_offset(BlockDriverState *bs, VmdkMetaData *m_data, @@ -597,7 +597,7 @@ static uint64_t get_cluster_offset(BlockDriverState *bs, VmdkMetaData *m_data,
597 return cluster_offset; 597 return cluster_offset;
598 } 598 }
599 599
600 -static int vmdk_is_allocated(BlockDriverState *bs, int64_t sector_num, 600 +static int vmdk_is_allocated(BlockDriverState *bs, int64_t sector_num,
601 int nb_sectors, int *pnum) 601 int nb_sectors, int *pnum)
602 { 602 {
603 BDRVVmdkState *s = bs->opaque; 603 BDRVVmdkState *s = bs->opaque;
@@ -613,7 +613,7 @@ static int vmdk_is_allocated(BlockDriverState *bs, int64_t sector_num, @@ -613,7 +613,7 @@ static int vmdk_is_allocated(BlockDriverState *bs, int64_t sector_num,
613 return (cluster_offset != 0); 613 return (cluster_offset != 0);
614 } 614 }
615 615
616 -static int vmdk_read(BlockDriverState *bs, int64_t sector_num, 616 +static int vmdk_read(BlockDriverState *bs, int64_t sector_num,
617 uint8_t *buf, int nb_sectors) 617 uint8_t *buf, int nb_sectors)
618 { 618 {
619 BDRVVmdkState *s = bs->opaque; 619 BDRVVmdkState *s = bs->opaque;
@@ -648,7 +648,7 @@ static int vmdk_read(BlockDriverState *bs, int64_t sector_num, @@ -648,7 +648,7 @@ static int vmdk_read(BlockDriverState *bs, int64_t sector_num,
648 return 0; 648 return 0;
649 } 649 }
650 650
651 -static int vmdk_write(BlockDriverState *bs, int64_t sector_num, 651 +static int vmdk_write(BlockDriverState *bs, int64_t sector_num,
652 const uint8_t *buf, int nb_sectors) 652 const uint8_t *buf, int nb_sectors)
653 { 653 {
654 BDRVVmdkState *s = bs->opaque; 654 BDRVVmdkState *s = bs->opaque;
@@ -761,8 +761,8 @@ static int vmdk_create(const char *filename, int64_t total_size, @@ -761,8 +761,8 @@ static int vmdk_create(const char *filename, int64_t total_size,
761 header.check_bytes[1] = 0x20; 761 header.check_bytes[1] = 0x20;
762 header.check_bytes[2] = 0xd; 762 header.check_bytes[2] = 0xd;
763 header.check_bytes[3] = 0xa; 763 header.check_bytes[3] = 0xa;
764 -  
765 - /* write all the data */ 764 +
  765 + /* write all the data */
766 write(fd, &magic, sizeof(magic)); 766 write(fd, &magic, sizeof(magic));
767 write(fd, &header, sizeof(header)); 767 write(fd, &header, sizeof(header));
768 768
@@ -773,7 +773,7 @@ static int vmdk_create(const char *filename, int64_t total_size, @@ -773,7 +773,7 @@ static int vmdk_create(const char *filename, int64_t total_size,
773 for (i = 0, tmp = header.rgd_offset + gd_size; 773 for (i = 0, tmp = header.rgd_offset + gd_size;
774 i < gt_count; i++, tmp += gt_size) 774 i < gt_count; i++, tmp += gt_size)
775 write(fd, &tmp, sizeof(tmp)); 775 write(fd, &tmp, sizeof(tmp));
776 - 776 +
777 /* write backup grain directory */ 777 /* write backup grain directory */
778 lseek(fd, le64_to_cpu(header.gd_offset) << 9, SEEK_SET); 778 lseek(fd, le64_to_cpu(header.gd_offset) << 9, SEEK_SET);
779 for (i = 0, tmp = header.gd_offset + gd_size; 779 for (i = 0, tmp = header.gd_offset + gd_size;
block-vpc.c
1 /* 1 /*
2 * Block driver for Conectix/Microsoft Virtual PC images 2 * Block driver for Conectix/Microsoft Virtual PC images
3 - * 3 + *
4 * Copyright (c) 2005 Alex Beregszaszi 4 * Copyright (c) 2005 Alex Beregszaszi
5 - * 5 + *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy 6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal 7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights 8 * in the Software without restriction, including without limitation the rights
@@ -65,7 +65,7 @@ struct vpc_subheader { @@ -65,7 +65,7 @@ struct vpc_subheader {
65 65
66 typedef struct BDRVVPCState { 66 typedef struct BDRVVPCState {
67 int fd; 67 int fd;
68 - 68 +
69 int pagetable_entries; 69 int pagetable_entries;
70 uint32_t *pagetable; 70 uint32_t *pagetable;
71 71
@@ -74,7 +74,7 @@ typedef struct BDRVVPCState { @@ -74,7 +74,7 @@ typedef struct BDRVVPCState {
74 uint8_t *pageentry_u8; 74 uint8_t *pageentry_u8;
75 uint32_t *pageentry_u32; 75 uint32_t *pageentry_u32;
76 uint16_t *pageentry_u16; 76 uint16_t *pageentry_u16;
77 - 77 +
78 uint64_t last_bitmap; 78 uint64_t last_bitmap;
79 #endif 79 #endif
80 } BDRVVPCState; 80 } BDRVVPCState;
@@ -97,7 +97,7 @@ static int vpc_open(BlockDriverState *bs, const char *filename, int flags) @@ -97,7 +97,7 @@ static int vpc_open(BlockDriverState *bs, const char *filename, int flags)
97 return -1; 97 return -1;
98 98
99 bs->read_only = 1; // no write support yet 99 bs->read_only = 1; // no write support yet
100 - 100 +
101 s->fd = fd; 101 s->fd = fd;
102 102
103 if (read(fd, &header, HEADER_SIZE) != HEADER_SIZE) 103 if (read(fd, &header, HEADER_SIZE) != HEADER_SIZE)
@@ -153,13 +153,13 @@ static inline int seek_to_sector(BlockDriverState *bs, int64_t sector_num) @@ -153,13 +153,13 @@ static inline int seek_to_sector(BlockDriverState *bs, int64_t sector_num)
153 153
154 pagetable_index = offset / s->pageentry_size; 154 pagetable_index = offset / s->pageentry_size;
155 pageentry_index = (offset % s->pageentry_size) / 512; 155 pageentry_index = (offset % s->pageentry_size) / 512;
156 - 156 +
157 if (pagetable_index > s->pagetable_entries || s->pagetable[pagetable_index] == 0xffffffff) 157 if (pagetable_index > s->pagetable_entries || s->pagetable[pagetable_index] == 0xffffffff)
158 return -1; // not allocated 158 return -1; // not allocated
159 159
160 bitmap_offset = 512 * s->pagetable[pagetable_index]; 160 bitmap_offset = 512 * s->pagetable[pagetable_index];
161 block_offset = bitmap_offset + 512 + (512 * pageentry_index); 161 block_offset = bitmap_offset + 512 + (512 * pageentry_index);
162 - 162 +
163 // printf("sector: %" PRIx64 ", index: %x, offset: %x, bioff: %" PRIx64 ", bloff: %" PRIx64 "\n", 163 // printf("sector: %" PRIx64 ", index: %x, offset: %x, bioff: %" PRIx64 ", bloff: %" PRIx64 "\n",
164 // sector_num, pagetable_index, pageentry_index, 164 // sector_num, pagetable_index, pageentry_index,
165 // bitmap_offset, block_offset); 165 // bitmap_offset, block_offset);
@@ -172,7 +172,7 @@ static inline int seek_to_sector(BlockDriverState *bs, int64_t sector_num) @@ -172,7 +172,7 @@ static inline int seek_to_sector(BlockDriverState *bs, int64_t sector_num)
172 lseek(s->fd, bitmap_offset, SEEK_SET); 172 lseek(s->fd, bitmap_offset, SEEK_SET);
173 173
174 s->last_bitmap = bitmap_offset; 174 s->last_bitmap = bitmap_offset;
175 - 175 +
176 // Scary! Bitmap is stored as big endian 32bit entries, 176 // Scary! Bitmap is stored as big endian 32bit entries,
177 // while we used to look it up byte by byte 177 // while we used to look it up byte by byte
178 read(s->fd, s->pageentry_u8, 512); 178 read(s->fd, s->pageentry_u8, 512);
@@ -184,7 +184,7 @@ static inline int seek_to_sector(BlockDriverState *bs, int64_t sector_num) @@ -184,7 +184,7 @@ static inline int seek_to_sector(BlockDriverState *bs, int64_t sector_num)
184 return -1; 184 return -1;
185 #else 185 #else
186 lseek(s->fd, bitmap_offset + (pageentry_index / 8), SEEK_SET); 186 lseek(s->fd, bitmap_offset + (pageentry_index / 8), SEEK_SET);
187 - 187 +
188 read(s->fd, &bitmap_entry, 1); 188 read(s->fd, &bitmap_entry, 1);
189 189
190 if ((bitmap_entry >> (pageentry_index % 8)) & 1) 190 if ((bitmap_entry >> (pageentry_index % 8)) & 1)
@@ -196,7 +196,7 @@ static inline int seek_to_sector(BlockDriverState *bs, int64_t sector_num) @@ -196,7 +196,7 @@ static inline int seek_to_sector(BlockDriverState *bs, int64_t sector_num)
196 return 0; 196 return 0;
197 } 197 }
198 198
199 -static int vpc_read(BlockDriverState *bs, int64_t sector_num, 199 +static int vpc_read(BlockDriverState *bs, int64_t sector_num,
200 uint8_t *buf, int nb_sectors) 200 uint8_t *buf, int nb_sectors)
201 { 201 {
202 BDRVVPCState *s = bs->opaque; 202 BDRVVPCState *s = bs->opaque;
block-vvfat.c
1 /* vim:set shiftwidth=4 ts=8: */ 1 /* vim:set shiftwidth=4 ts=8: */
2 /* 2 /*
3 * QEMU Block driver for virtual VFAT (shadows a local directory) 3 * QEMU Block driver for virtual VFAT (shadows a local directory)
4 - * 4 + *
5 * Copyright (c) 2004,2005 Johannes E. Schindelin 5 * Copyright (c) 2004,2005 Johannes E. Schindelin
6 - * 6 + *
7 * Permission is hereby granted, free of charge, to any person obtaining a copy 7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal 8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights 9 * in the Software without restriction, including without limitation the rights
@@ -38,7 +38,7 @@ @@ -38,7 +38,7 @@
38 /* TODO: add ":bootsector=blabla.img:" */ 38 /* TODO: add ":bootsector=blabla.img:" */
39 /* LATER TODO: add automatic boot sector generation from 39 /* LATER TODO: add automatic boot sector generation from
40 BOOTEASY.ASM and Ranish Partition Manager 40 BOOTEASY.ASM and Ranish Partition Manager
41 - Note that DOS assumes the system files to be the first files in the 41 + Note that DOS assumes the system files to be the first files in the
42 file system (test if the boot sector still relies on that fact)! */ 42 file system (test if the boot sector still relies on that fact)! */
43 /* MAYBE TODO: write block-visofs.c */ 43 /* MAYBE TODO: write block-visofs.c */
44 /* TODO: call try_commit() only after a timeout */ 44 /* TODO: call try_commit() only after a timeout */
@@ -153,7 +153,7 @@ static inline int array_roll(array_t* array,int index_to,int index_from,int coun @@ -153,7 +153,7 @@ static inline int array_roll(array_t* array,int index_to,int index_from,int coun
153 index_to<0 || index_to>=array->next || 153 index_to<0 || index_to>=array->next ||
154 index_from<0 || index_from>=array->next) 154 index_from<0 || index_from>=array->next)
155 return -1; 155 return -1;
156 - 156 +
157 if(index_to==index_from) 157 if(index_to==index_from)
158 return 0; 158 return 0;
159 159
@@ -167,7 +167,7 @@ static inline int array_roll(array_t* array,int index_to,int index_from,int coun @@ -167,7 +167,7 @@ static inline int array_roll(array_t* array,int index_to,int index_from,int coun
167 memmove(to+is*count,to,from-to); 167 memmove(to+is*count,to,from-to);
168 else 168 else
169 memmove(from,from+is*count,to-from); 169 memmove(from,from+is*count,to-from);
170 - 170 +
171 memcpy(to,buf,is*count); 171 memcpy(to,buf,is*count);
172 172
173 free(buf); 173 free(buf);
@@ -319,10 +319,10 @@ typedef struct BDRVVVFATState { @@ -319,10 +319,10 @@ typedef struct BDRVVVFATState {
319 BlockDriverState* bs; /* pointer to parent */ 319 BlockDriverState* bs; /* pointer to parent */
320 unsigned int first_sectors_number; /* 1 for a single partition, 0x40 for a disk with partition table */ 320 unsigned int first_sectors_number; /* 1 for a single partition, 0x40 for a disk with partition table */
321 unsigned char first_sectors[0x40*0x200]; 321 unsigned char first_sectors[0x40*0x200];
322 - 322 +
323 int fat_type; /* 16 or 32 */ 323 int fat_type; /* 16 or 32 */
324 array_t fat,directory,mapping; 324 array_t fat,directory,mapping;
325 - 325 +
326 unsigned int cluster_size; 326 unsigned int cluster_size;
327 unsigned int sectors_per_cluster; 327 unsigned int sectors_per_cluster;
328 unsigned int sectors_per_fat; 328 unsigned int sectors_per_fat;
@@ -332,7 +332,7 @@ typedef struct BDRVVVFATState { @@ -332,7 +332,7 @@ typedef struct BDRVVVFATState {
332 uint32_t sector_count; /* total number of sectors of the partition */ 332 uint32_t sector_count; /* total number of sectors of the partition */
333 uint32_t cluster_count; /* total number of clusters of this partition */ 333 uint32_t cluster_count; /* total number of clusters of this partition */
334 uint32_t max_fat_value; 334 uint32_t max_fat_value;
335 - 335 +
336 int current_fd; 336 int current_fd;
337 mapping_t* current_mapping; 337 mapping_t* current_mapping;
338 unsigned char* cluster; /* points to current cluster */ 338 unsigned char* cluster; /* points to current cluster */
@@ -358,7 +358,7 @@ static void init_mbr(BDRVVVFATState* s) @@ -358,7 +358,7 @@ static void init_mbr(BDRVVVFATState* s)
358 partition_t* partition=&(real_mbr->partition[0]); 358 partition_t* partition=&(real_mbr->partition[0]);
359 359
360 memset(s->first_sectors,0,512); 360 memset(s->first_sectors,0,512);
361 - 361 +
362 partition->attributes=0x80; /* bootable */ 362 partition->attributes=0x80; /* bootable */
363 partition->start_head=1; 363 partition->start_head=1;
364 partition->start_sector=1; 364 partition->start_sector=1;
@@ -478,7 +478,7 @@ static inline uint8_t fat_chksum(const direntry_t* entry) @@ -478,7 +478,7 @@ static inline uint8_t fat_chksum(const direntry_t* entry)
478 for(i=0;i<11;i++) 478 for(i=0;i<11;i++)
479 chksum=(((chksum&0xfe)>>1)|((chksum&0x01)?0x80:0)) 479 chksum=(((chksum&0xfe)>>1)|((chksum&0x01)?0x80:0))
480 +(unsigned char)entry->name[i]; 480 +(unsigned char)entry->name[i];
481 - 481 +
482 return chksum; 482 return chksum;
483 } 483 }
484 484
@@ -554,7 +554,7 @@ static inline void init_fat(BDRVVVFATState* s) @@ -554,7 +554,7 @@ static inline void init_fat(BDRVVVFATState* s)
554 s->sectors_per_fat * 0x200 / s->fat.item_size - 1); 554 s->sectors_per_fat * 0x200 / s->fat.item_size - 1);
555 } 555 }
556 memset(s->fat.pointer,0,s->fat.size); 556 memset(s->fat.pointer,0,s->fat.size);
557 - 557 +
558 switch(s->fat_type) { 558 switch(s->fat_type) {
559 case 12: s->max_fat_value=0xfff; break; 559 case 12: s->max_fat_value=0xfff; break;
560 case 16: s->max_fat_value=0xffff; break; 560 case 16: s->max_fat_value=0xffff; break;
@@ -579,10 +579,10 @@ static inline direntry_t* create_short_and_long_name(BDRVVVFATState* s, @@ -579,10 +579,10 @@ static inline direntry_t* create_short_and_long_name(BDRVVVFATState* s,
579 memcpy(entry->name,filename,strlen(filename)); 579 memcpy(entry->name,filename,strlen(filename));
580 return entry; 580 return entry;
581 } 581 }
582 - 582 +
583 entry_long=create_long_filename(s,filename); 583 entry_long=create_long_filename(s,filename);
584 -  
585 - i = strlen(filename); 584 +
  585 + i = strlen(filename);
586 for(j = i - 1; j>0 && filename[j]!='.';j--); 586 for(j = i - 1; j>0 && filename[j]!='.';j--);
587 if (j > 0) 587 if (j > 0)
588 i = (j > 8 ? 8 : j); 588 i = (j > 8 ? 8 : j);
@@ -592,7 +592,7 @@ static inline direntry_t* create_short_and_long_name(BDRVVVFATState* s, @@ -592,7 +592,7 @@ static inline direntry_t* create_short_and_long_name(BDRVVVFATState* s,
592 entry=array_get_next(&(s->directory)); 592 entry=array_get_next(&(s->directory));
593 memset(entry->name,0x20,11); 593 memset(entry->name,0x20,11);
594 strncpy(entry->name,filename,i); 594 strncpy(entry->name,filename,i);
595 - 595 +
596 if(j > 0) 596 if(j > 0)
597 for (i = 0; i < 3 && filename[j+1+i]; i++) 597 for (i = 0; i < 3 && filename[j+1+i]; i++)
598 entry->extension[i] = filename[j+1+i]; 598 entry->extension[i] = filename[j+1+i];
@@ -618,7 +618,7 @@ static inline direntry_t* create_short_and_long_name(BDRVVVFATState* s, @@ -618,7 +618,7 @@ static inline direntry_t* create_short_and_long_name(BDRVVVFATState* s,
618 if(entry1==entry) /* no dupe found */ 618 if(entry1==entry) /* no dupe found */
619 break; 619 break;
620 620
621 - /* use all 8 characters of name */ 621 + /* use all 8 characters of name */
622 if(entry->name[7]==' ') { 622 if(entry->name[7]==' ') {
623 int j; 623 int j;
624 for(j=6;j>0 && entry->name[j]==' ';j--) 624 for(j=6;j>0 && entry->name[j]==' ';j--)
@@ -675,11 +675,11 @@ static int read_directory(BDRVVVFATState* s, int mapping_index) @@ -675,11 +675,11 @@ static int read_directory(BDRVVVFATState* s, int mapping_index)
675 mapping->end = mapping->begin; 675 mapping->end = mapping->begin;
676 return -1; 676 return -1;
677 } 677 }
678 - 678 +
679 i = mapping->info.dir.first_dir_index = 679 i = mapping->info.dir.first_dir_index =
680 first_cluster == 0 ? 0 : s->directory.next; 680 first_cluster == 0 ? 0 : s->directory.next;
681 681
682 - /* actually read the directory, and allocate the mappings */ 682 + /* actually read the directory, and allocate the mappings */
683 while((entry=readdir(dir))) { 683 while((entry=readdir(dir))) {
684 unsigned int length=strlen(dirname)+2+strlen(entry->d_name); 684 unsigned int length=strlen(dirname)+2+strlen(entry->d_name);
685 char* buffer; 685 char* buffer;
@@ -690,7 +690,7 @@ static int read_directory(BDRVVVFATState* s, int mapping_index) @@ -690,7 +690,7 @@ static int read_directory(BDRVVVFATState* s, int mapping_index)
690 690
691 if(first_cluster == 0 && (is_dotdot || is_dot)) 691 if(first_cluster == 0 && (is_dotdot || is_dot))
692 continue; 692 continue;
693 - 693 +
694 buffer=(char*)malloc(length); 694 buffer=(char*)malloc(length);
695 assert(buffer); 695 assert(buffer);
696 snprintf(buffer,length,"%s/%s",dirname,entry->d_name); 696 snprintf(buffer,length,"%s/%s",dirname,entry->d_name);
@@ -765,7 +765,7 @@ static int read_directory(BDRVVVFATState* s, int mapping_index) @@ -765,7 +765,7 @@ static int read_directory(BDRVVVFATState* s, int mapping_index)
765 memset(array_get(&(s->directory), cur), 0, 765 memset(array_get(&(s->directory), cur), 0,
766 (ROOT_ENTRIES - cur) * sizeof(direntry_t)); 766 (ROOT_ENTRIES - cur) * sizeof(direntry_t));
767 } 767 }
768 - 768 +
769 /* reget the mapping, since s->mapping was possibly realloc()ed */ 769 /* reget the mapping, since s->mapping was possibly realloc()ed */
770 mapping = (mapping_t*)array_get(&(s->mapping), mapping_index); 770 mapping = (mapping_t*)array_get(&(s->mapping), mapping_index);
771 first_cluster += (s->directory.next - mapping->info.dir.first_dir_index) 771 first_cluster += (s->directory.next - mapping->info.dir.first_dir_index)
@@ -774,7 +774,7 @@ static int read_directory(BDRVVVFATState* s, int mapping_index) @@ -774,7 +774,7 @@ static int read_directory(BDRVVVFATState* s, int mapping_index)
774 774
775 direntry = (direntry_t*)array_get(&(s->directory), mapping->dir_index); 775 direntry = (direntry_t*)array_get(&(s->directory), mapping->dir_index);
776 set_begin_of_direntry(direntry, mapping->begin); 776 set_begin_of_direntry(direntry, mapping->begin);
777 - 777 +
778 return 0; 778 return 0;
779 } 779 }
780 780
@@ -825,7 +825,7 @@ static int init_directories(BDRVVVFATState* s, @@ -825,7 +825,7 @@ static int init_directories(BDRVVVFATState* s,
825 */ 825 */
826 i = 1+s->sectors_per_cluster*0x200*8/s->fat_type; 826 i = 1+s->sectors_per_cluster*0x200*8/s->fat_type;
827 s->sectors_per_fat=(s->sector_count+i)/i; /* round up */ 827 s->sectors_per_fat=(s->sector_count+i)/i; /* round up */
828 - 828 +
829 array_init(&(s->mapping),sizeof(mapping_t)); 829 array_init(&(s->mapping),sizeof(mapping_t));
830 array_init(&(s->directory),sizeof(direntry_t)); 830 array_init(&(s->directory),sizeof(direntry_t));
831 831
@@ -857,7 +857,7 @@ static int init_directories(BDRVVVFATState* s, @@ -857,7 +857,7 @@ static int init_directories(BDRVVVFATState* s,
857 857
858 for (i = 0, cluster = 0; i < s->mapping.next; i++) { 858 for (i = 0, cluster = 0; i < s->mapping.next; i++) {
859 int j; 859 int j;
860 - /* MS-DOS expects the FAT to be 0 for the root directory 860 + /* MS-DOS expects the FAT to be 0 for the root directory
861 * (except for the media byte). */ 861 * (except for the media byte). */
862 /* LATER TODO: still true for FAT32? */ 862 /* LATER TODO: still true for FAT32? */
863 int fix_fat = (i != 0); 863 int fix_fat = (i != 0);
@@ -987,7 +987,7 @@ DLOG(if (stderr == NULL) { @@ -987,7 +987,7 @@ DLOG(if (stderr == NULL) {
987 s->qcow_filename = NULL; 987 s->qcow_filename = NULL;
988 s->fat2 = NULL; 988 s->fat2 = NULL;
989 s->downcase_short_names = 1; 989 s->downcase_short_names = 1;
990 - 990 +
991 if (!strstart(dirname, "fat:", NULL)) 991 if (!strstart(dirname, "fat:", NULL))
992 return -1; 992 return -1;
993 993
@@ -1076,7 +1076,7 @@ static inline int find_mapping_for_cluster_aux(BDRVVVFATState* s,int cluster_num @@ -1076,7 +1076,7 @@ static inline int find_mapping_for_cluster_aux(BDRVVVFATState* s,int cluster_num
1076 assert(index1<=index2); 1076 assert(index1<=index2);
1077 DLOG(mapping=array_get(&(s->mapping),index1); 1077 DLOG(mapping=array_get(&(s->mapping),index1);
1078 assert(mapping->begin<=cluster_num); 1078 assert(mapping->begin<=cluster_num);
1079 - assert(index2 >= s->mapping.next || 1079 + assert(index2 >= s->mapping.next ||
1080 ((mapping = array_get(&(s->mapping),index2)) && 1080 ((mapping = array_get(&(s->mapping),index2)) &&
1081 mapping->end>cluster_num))); 1081 mapping->end>cluster_num)));
1082 } 1082 }
@@ -1239,7 +1239,7 @@ static void print_mapping(const mapping_t* mapping) @@ -1239,7 +1239,7 @@ static void print_mapping(const mapping_t* mapping)
1239 } 1239 }
1240 #endif 1240 #endif
1241 1241
1242 -static int vvfat_read(BlockDriverState *bs, int64_t sector_num, 1242 +static int vvfat_read(BlockDriverState *bs, int64_t sector_num,
1243 uint8_t *buf, int nb_sectors) 1243 uint8_t *buf, int nb_sectors)
1244 { 1244 {
1245 BDRVVVFATState *s = bs->opaque; 1245 BDRVVVFATState *s = bs->opaque;
@@ -1674,7 +1674,7 @@ static uint32_t get_cluster_count_for_direntry(BDRVVVFATState* s, @@ -1674,7 +1674,7 @@ static uint32_t get_cluster_count_for_direntry(BDRVVVFATState* s,
1674 } 1674 }
1675 1675
1676 /* 1676 /*
1677 - * This function looks at the modified data (qcow). 1677 + * This function looks at the modified data (qcow).
1678 * It returns 0 upon inconsistency or error, and the number of clusters 1678 * It returns 0 upon inconsistency or error, and the number of clusters
1679 * used by the directory, its subdirectories and their files. 1679 * used by the directory, its subdirectories and their files.
1680 */ 1680 */
@@ -1709,7 +1709,7 @@ static int check_directory_consistency(BDRVVVFATState *s, @@ -1709,7 +1709,7 @@ static int check_directory_consistency(BDRVVVFATState *s,
1709 } else 1709 } else
1710 /* new directory */ 1710 /* new directory */
1711 schedule_mkdir(s, cluster_num, strdup(path)); 1711 schedule_mkdir(s, cluster_num, strdup(path));
1712 - 1712 +
1713 lfn_init(&lfn); 1713 lfn_init(&lfn);
1714 do { 1714 do {
1715 int i; 1715 int i;
@@ -2049,7 +2049,7 @@ static int commit_mappings(BDRVVVFATState* s, @@ -2049,7 +2049,7 @@ static int commit_mappings(BDRVVVFATState* s,
2049 } 2049 }
2050 2050
2051 next_mapping->dir_index = mapping->dir_index; 2051 next_mapping->dir_index = mapping->dir_index;
2052 - next_mapping->first_mapping_index = 2052 + next_mapping->first_mapping_index =
2053 mapping->first_mapping_index < 0 ? 2053 mapping->first_mapping_index < 0 ?
2054 array_index(&(s->mapping), mapping) : 2054 array_index(&(s->mapping), mapping) :
2055 mapping->first_mapping_index; 2055 mapping->first_mapping_index;
@@ -2069,7 +2069,7 @@ static int commit_mappings(BDRVVVFATState* s, @@ -2069,7 +2069,7 @@ static int commit_mappings(BDRVVVFATState* s,
2069 2069
2070 mapping = next_mapping; 2070 mapping = next_mapping;
2071 } 2071 }
2072 - 2072 +
2073 cluster = c1; 2073 cluster = c1;
2074 } 2074 }
2075 2075
@@ -2555,7 +2555,7 @@ static int do_commit(BDRVVVFATState* s) @@ -2555,7 +2555,7 @@ static int do_commit(BDRVVVFATState* s)
2555 return ret; 2555 return ret;
2556 } 2556 }
2557 2557
2558 - /* copy FAT (with bdrv_read) */ 2558 + /* copy FAT (with bdrv_read) */
2559 memcpy(s->fat.pointer, s->fat2, 0x200 * s->sectors_per_fat); 2559 memcpy(s->fat.pointer, s->fat2, 0x200 * s->sectors_per_fat);
2560 2560
2561 /* recurse direntries from root (using bs->bdrv_read) */ 2561 /* recurse direntries from root (using bs->bdrv_read) */
@@ -2597,10 +2597,10 @@ DLOG(checkpoint()); @@ -2597,10 +2597,10 @@ DLOG(checkpoint());
2597 return do_commit(s); 2597 return do_commit(s);
2598 } 2598 }
2599 2599
2600 -static int vvfat_write(BlockDriverState *bs, int64_t sector_num, 2600 +static int vvfat_write(BlockDriverState *bs, int64_t sector_num,
2601 const uint8_t *buf, int nb_sectors) 2601 const uint8_t *buf, int nb_sectors)
2602 { 2602 {
2603 - BDRVVVFATState *s = bs->opaque; 2603 + BDRVVVFATState *s = bs->opaque;
2604 int i, ret; 2604 int i, ret;
2605 2605
2606 DLOG(checkpoint()); 2606 DLOG(checkpoint());
@@ -2639,7 +2639,7 @@ DLOG(checkpoint()); @@ -2639,7 +2639,7 @@ DLOG(checkpoint());
2639 begin = sector_num; 2639 begin = sector_num;
2640 if (end > sector_num + nb_sectors) 2640 if (end > sector_num + nb_sectors)
2641 end = sector_num + nb_sectors; 2641 end = sector_num + nb_sectors;
2642 - dir_index = mapping->dir_index + 2642 + dir_index = mapping->dir_index +
2643 0x10 * (begin - mapping->begin * s->sectors_per_cluster); 2643 0x10 * (begin - mapping->begin * s->sectors_per_cluster);
2644 direntries = (direntry_t*)(buf + 0x200 * (begin - sector_num)); 2644 direntries = (direntry_t*)(buf + 0x200 * (begin - sector_num));
2645 2645
@@ -2698,7 +2698,7 @@ static int vvfat_is_allocated(BlockDriverState *bs, @@ -2698,7 +2698,7 @@ static int vvfat_is_allocated(BlockDriverState *bs,
2698 *n = nb_sectors; 2698 *n = nb_sectors;
2699 else if (*n < 0) 2699 else if (*n < 0)
2700 return 0; 2700 return 0;
2701 - return 1; 2701 + return 1;
2702 } 2702 }
2703 2703
2704 static int write_target_commit(BlockDriverState *bs, int64_t sector_num, 2704 static int write_target_commit(BlockDriverState *bs, int64_t sector_num,
1 /* 1 /*
2 * QEMU System Emulator block driver 2 * QEMU System Emulator block driver
3 - * 3 + *
4 * Copyright (c) 2003 Fabrice Bellard 4 * Copyright (c) 2003 Fabrice Bellard
5 - * 5 + *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy 6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal 7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights 8 * in the Software without restriction, including without limitation the rights
@@ -48,7 +48,7 @@ static BlockDriverAIOCB *bdrv_aio_write_em(BlockDriverState *bs, @@ -48,7 +48,7 @@ static BlockDriverAIOCB *bdrv_aio_write_em(BlockDriverState *bs,
48 int64_t sector_num, const uint8_t *buf, int nb_sectors, 48 int64_t sector_num, const uint8_t *buf, int nb_sectors,
49 BlockDriverCompletionFunc *cb, void *opaque); 49 BlockDriverCompletionFunc *cb, void *opaque);
50 static void bdrv_aio_cancel_em(BlockDriverAIOCB *acb); 50 static void bdrv_aio_cancel_em(BlockDriverAIOCB *acb);
51 -static int bdrv_read_em(BlockDriverState *bs, int64_t sector_num, 51 +static int bdrv_read_em(BlockDriverState *bs, int64_t sector_num,
52 uint8_t *buf, int nb_sectors); 52 uint8_t *buf, int nb_sectors);
53 static int bdrv_write_em(BlockDriverState *bs, int64_t sector_num, 53 static int bdrv_write_em(BlockDriverState *bs, int64_t sector_num,
54 const uint8_t *buf, int nb_sectors); 54 const uint8_t *buf, int nb_sectors);
@@ -167,7 +167,7 @@ BlockDriver *bdrv_find_format(const char *format_name) @@ -167,7 +167,7 @@ BlockDriver *bdrv_find_format(const char *format_name)
167 return NULL; 167 return NULL;
168 } 168 }
169 169
170 -int bdrv_create(BlockDriver *drv, 170 +int bdrv_create(BlockDriver *drv,
171 const char *filename, int64_t size_in_sectors, 171 const char *filename, int64_t size_in_sectors,
172 const char *backing_file, int flags) 172 const char *backing_file, int flags)
173 { 173 {
@@ -180,7 +180,7 @@ int bdrv_create(BlockDriver *drv, @@ -180,7 +180,7 @@ int bdrv_create(BlockDriver *drv,
180 void get_tmp_filename(char *filename, int size) 180 void get_tmp_filename(char *filename, int size)
181 { 181 {
182 char temp_dir[MAX_PATH]; 182 char temp_dir[MAX_PATH];
183 - 183 +
184 GetTempPath(MAX_PATH, temp_dir); 184 GetTempPath(MAX_PATH, temp_dir);
185 GetTempFileName(temp_dir, "qem", 0, filename); 185 GetTempFileName(temp_dir, "qem", 0, filename);
186 } 186 }
@@ -202,10 +202,10 @@ static int is_windows_drive_prefix(const char *filename) @@ -202,10 +202,10 @@ static int is_windows_drive_prefix(const char *filename)
202 (filename[0] >= 'A' && filename[0] <= 'Z')) && 202 (filename[0] >= 'A' && filename[0] <= 'Z')) &&
203 filename[1] == ':'); 203 filename[1] == ':');
204 } 204 }
205 - 205 +
206 static int is_windows_drive(const char *filename) 206 static int is_windows_drive(const char *filename)
207 { 207 {
208 - if (is_windows_drive_prefix(filename) && 208 + if (is_windows_drive_prefix(filename) &&
209 filename[2] == '\0') 209 filename[2] == '\0')
210 return 1; 210 return 1;
211 if (strstart(filename, "\\\\.\\", NULL) || 211 if (strstart(filename, "\\\\.\\", NULL) ||
@@ -236,7 +236,7 @@ static BlockDriver *find_protocol(const char *filename) @@ -236,7 +236,7 @@ static BlockDriver *find_protocol(const char *filename)
236 memcpy(protocol, filename, len); 236 memcpy(protocol, filename, len);
237 protocol[len] = '\0'; 237 protocol[len] = '\0';
238 for(drv1 = first_drv; drv1 != NULL; drv1 = drv1->next) { 238 for(drv1 = first_drv; drv1 != NULL; drv1 = drv1->next) {
239 - if (drv1->protocol_name && 239 + if (drv1->protocol_name &&
240 !strcmp(drv1->protocol_name, protocol)) 240 !strcmp(drv1->protocol_name, protocol))
241 return drv1; 241 return drv1;
242 } 242 }
@@ -251,7 +251,7 @@ static BlockDriver *find_image_format(const char *filename) @@ -251,7 +251,7 @@ static BlockDriver *find_image_format(const char *filename)
251 BlockDriver *drv1, *drv; 251 BlockDriver *drv1, *drv;
252 uint8_t buf[2048]; 252 uint8_t buf[2048];
253 BlockDriverState *bs; 253 BlockDriverState *bs;
254 - 254 +
255 /* detect host devices. By convention, /dev/cdrom[N] is always 255 /* detect host devices. By convention, /dev/cdrom[N] is always
256 recognized as a host CDROM */ 256 recognized as a host CDROM */
257 if (strstart(filename, "/dev/cdrom", NULL)) 257 if (strstart(filename, "/dev/cdrom", NULL))
@@ -262,13 +262,13 @@ static BlockDriver *find_image_format(const char *filename) @@ -262,13 +262,13 @@ static BlockDriver *find_image_format(const char *filename)
262 #else 262 #else
263 { 263 {
264 struct stat st; 264 struct stat st;
265 - if (stat(filename, &st) >= 0 && 265 + if (stat(filename, &st) >= 0 &&
266 (S_ISCHR(st.st_mode) || S_ISBLK(st.st_mode))) { 266 (S_ISCHR(st.st_mode) || S_ISBLK(st.st_mode))) {
267 return &bdrv_host_device; 267 return &bdrv_host_device;
268 } 268 }
269 } 269 }
270 #endif 270 #endif
271 - 271 +
272 drv = find_protocol(filename); 272 drv = find_protocol(filename);
273 /* no need to test disk image formats for vvfat */ 273 /* no need to test disk image formats for vvfat */
274 if (drv == &bdrv_vvfat) 274 if (drv == &bdrv_vvfat)
@@ -324,7 +324,7 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags, @@ -324,7 +324,7 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags,
324 int ret, open_flags; 324 int ret, open_flags;
325 char tmp_filename[PATH_MAX]; 325 char tmp_filename[PATH_MAX];
326 char backing_filename[PATH_MAX]; 326 char backing_filename[PATH_MAX];
327 - 327 +
328 bs->read_only = 0; 328 bs->read_only = 0;
329 bs->is_temporary = 0; 329 bs->is_temporary = 0;
330 bs->encrypted = 0; 330 bs->encrypted = 0;
@@ -332,7 +332,7 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags, @@ -332,7 +332,7 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags,
332 if (flags & BDRV_O_SNAPSHOT) { 332 if (flags & BDRV_O_SNAPSHOT) {
333 BlockDriverState *bs1; 333 BlockDriverState *bs1;
334 int64_t total_size; 334 int64_t total_size;
335 - 335 +
336 /* if snapshot, we create a temporary backing file and open it 336 /* if snapshot, we create a temporary backing file and open it
337 instead of opening 'filename' directly */ 337 instead of opening 'filename' directly */
338 338
@@ -347,10 +347,10 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags, @@ -347,10 +347,10 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags,
347 } 347 }
348 total_size = bdrv_getlength(bs1) >> SECTOR_BITS; 348 total_size = bdrv_getlength(bs1) >> SECTOR_BITS;
349 bdrv_delete(bs1); 349 bdrv_delete(bs1);
350 - 350 +
351 get_tmp_filename(tmp_filename, sizeof(tmp_filename)); 351 get_tmp_filename(tmp_filename, sizeof(tmp_filename));
352 realpath(filename, backing_filename); 352 realpath(filename, backing_filename);
353 - if (bdrv_create(&bdrv_qcow2, tmp_filename, 353 + if (bdrv_create(&bdrv_qcow2, tmp_filename,
354 total_size, backing_filename, 0) < 0) { 354 total_size, backing_filename, 0) < 0) {
355 return -1; 355 return -1;
356 } 356 }
@@ -494,7 +494,7 @@ int bdrv_commit(BlockDriverState *bs) @@ -494,7 +494,7 @@ int bdrv_commit(BlockDriverState *bs)
494 } 494 }
495 495
496 /* return < 0 if error. See bdrv_write() for the return codes */ 496 /* return < 0 if error. See bdrv_write() for the return codes */
497 -int bdrv_read(BlockDriverState *bs, int64_t sector_num, 497 +int bdrv_read(BlockDriverState *bs, int64_t sector_num,
498 uint8_t *buf, int nb_sectors) 498 uint8_t *buf, int nb_sectors)
499 { 499 {
500 BlockDriver *drv = bs->drv; 500 BlockDriver *drv = bs->drv;
@@ -525,13 +525,13 @@ int bdrv_read(BlockDriverState *bs, int64_t sector_num, @@ -525,13 +525,13 @@ int bdrv_read(BlockDriverState *bs, int64_t sector_num,
525 } 525 }
526 } 526 }
527 527
528 -/* Return < 0 if error. Important errors are: 528 +/* Return < 0 if error. Important errors are:
529 -EIO generic I/O error (may happen for all errors) 529 -EIO generic I/O error (may happen for all errors)
530 -ENOMEDIUM No media inserted. 530 -ENOMEDIUM No media inserted.
531 -EINVAL Invalid sector number or nb_sectors 531 -EINVAL Invalid sector number or nb_sectors
532 -EACCES Trying to write a read-only device 532 -EACCES Trying to write a read-only device
533 */ 533 */
534 -int bdrv_write(BlockDriverState *bs, int64_t sector_num, 534 +int bdrv_write(BlockDriverState *bs, int64_t sector_num,
535 const uint8_t *buf, int nb_sectors) 535 const uint8_t *buf, int nb_sectors)
536 { 536 {
537 BlockDriver *drv = bs->drv; 537 BlockDriver *drv = bs->drv;
@@ -540,7 +540,7 @@ int bdrv_write(BlockDriverState *bs, int64_t sector_num, @@ -540,7 +540,7 @@ int bdrv_write(BlockDriverState *bs, int64_t sector_num,
540 if (bs->read_only) 540 if (bs->read_only)
541 return -EACCES; 541 return -EACCES;
542 if (sector_num == 0 && bs->boot_sector_enabled && nb_sectors > 0) { 542 if (sector_num == 0 && bs->boot_sector_enabled && nb_sectors > 0) {
543 - memcpy(bs->boot_sector_data, buf, 512); 543 + memcpy(bs->boot_sector_data, buf, 512);
544 } 544 }
545 if (drv->bdrv_pwrite) { 545 if (drv->bdrv_pwrite) {
546 int ret, len; 546 int ret, len;
@@ -557,7 +557,7 @@ int bdrv_write(BlockDriverState *bs, int64_t sector_num, @@ -557,7 +557,7 @@ int bdrv_write(BlockDriverState *bs, int64_t sector_num,
557 } 557 }
558 } 558 }
559 559
560 -static int bdrv_pread_em(BlockDriverState *bs, int64_t offset, 560 +static int bdrv_pread_em(BlockDriverState *bs, int64_t offset,
561 uint8_t *buf, int count1) 561 uint8_t *buf, int count1)
562 { 562 {
563 uint8_t tmp_buf[SECTOR_SIZE]; 563 uint8_t tmp_buf[SECTOR_SIZE];
@@ -601,7 +601,7 @@ static int bdrv_pread_em(BlockDriverState *bs, int64_t offset, @@ -601,7 +601,7 @@ static int bdrv_pread_em(BlockDriverState *bs, int64_t offset,
601 return count1; 601 return count1;
602 } 602 }
603 603
604 -static int bdrv_pwrite_em(BlockDriverState *bs, int64_t offset, 604 +static int bdrv_pwrite_em(BlockDriverState *bs, int64_t offset,
605 const uint8_t *buf, int count1) 605 const uint8_t *buf, int count1)
606 { 606 {
607 uint8_t tmp_buf[SECTOR_SIZE]; 607 uint8_t tmp_buf[SECTOR_SIZE];
@@ -650,9 +650,9 @@ static int bdrv_pwrite_em(BlockDriverState *bs, int64_t offset, @@ -650,9 +650,9 @@ static int bdrv_pwrite_em(BlockDriverState *bs, int64_t offset,
650 } 650 }
651 651
652 /** 652 /**
653 - * Read with byte offsets (needed only for file protocols) 653 + * Read with byte offsets (needed only for file protocols)
654 */ 654 */
655 -int bdrv_pread(BlockDriverState *bs, int64_t offset, 655 +int bdrv_pread(BlockDriverState *bs, int64_t offset,
656 void *buf1, int count1) 656 void *buf1, int count1)
657 { 657 {
658 BlockDriver *drv = bs->drv; 658 BlockDriver *drv = bs->drv;
@@ -664,10 +664,10 @@ int bdrv_pread(BlockDriverState *bs, int64_t offset, @@ -664,10 +664,10 @@ int bdrv_pread(BlockDriverState *bs, int64_t offset,
664 return drv->bdrv_pread(bs, offset, buf1, count1); 664 return drv->bdrv_pread(bs, offset, buf1, count1);
665 } 665 }
666 666
667 -/**  
668 - * Write with byte offsets (needed only for file protocols) 667 +/**
  668 + * Write with byte offsets (needed only for file protocols)
669 */ 669 */
670 -int bdrv_pwrite(BlockDriverState *bs, int64_t offset, 670 +int bdrv_pwrite(BlockDriverState *bs, int64_t offset,
671 const void *buf1, int count1) 671 const void *buf1, int count1)
672 { 672 {
673 BlockDriver *drv = bs->drv; 673 BlockDriver *drv = bs->drv;
@@ -729,7 +729,7 @@ void bdrv_set_boot_sector(BlockDriverState *bs, const uint8_t *data, int size) @@ -729,7 +729,7 @@ void bdrv_set_boot_sector(BlockDriverState *bs, const uint8_t *data, int size)
729 memset(bs->boot_sector_data + size, 0, 512 - size); 729 memset(bs->boot_sector_data + size, 0, 512 - size);
730 } 730 }
731 731
732 -void bdrv_set_geometry_hint(BlockDriverState *bs, 732 +void bdrv_set_geometry_hint(BlockDriverState *bs,
733 int cyls, int heads, int secs) 733 int cyls, int heads, int secs)
734 { 734 {
735 bs->cyls = cyls; 735 bs->cyls = cyls;
@@ -749,7 +749,7 @@ void bdrv_set_translation_hint(BlockDriverState *bs, int translation) @@ -749,7 +749,7 @@ void bdrv_set_translation_hint(BlockDriverState *bs, int translation)
749 bs->translation = translation; 749 bs->translation = translation;
750 } 750 }
751 751
752 -void bdrv_get_geometry_hint(BlockDriverState *bs, 752 +void bdrv_get_geometry_hint(BlockDriverState *bs,
753 int *pcyls, int *pheads, int *psecs) 753 int *pcyls, int *pheads, int *psecs)
754 { 754 {
755 *pcyls = bs->cyls; 755 *pcyls = bs->cyls;
@@ -778,7 +778,7 @@ int bdrv_is_read_only(BlockDriverState *bs) @@ -778,7 +778,7 @@ int bdrv_is_read_only(BlockDriverState *bs)
778 } 778 }
779 779
780 /* XXX: no longer used */ 780 /* XXX: no longer used */
781 -void bdrv_set_change_cb(BlockDriverState *bs, 781 +void bdrv_set_change_cb(BlockDriverState *bs,
782 void (*change_cb)(void *opaque), void *opaque) 782 void (*change_cb)(void *opaque), void *opaque)
783 { 783 {
784 bs->change_cb = change_cb; 784 bs->change_cb = change_cb;
@@ -816,7 +816,7 @@ void bdrv_get_format(BlockDriverState *bs, char *buf, int buf_size) @@ -816,7 +816,7 @@ void bdrv_get_format(BlockDriverState *bs, char *buf, int buf_size)
816 } 816 }
817 } 817 }
818 818
819 -void bdrv_iterate_format(void (*it)(void *opaque, const char *name), 819 +void bdrv_iterate_format(void (*it)(void *opaque, const char *name),
820 void *opaque) 820 void *opaque)
821 { 821 {
822 BlockDriver *drv; 822 BlockDriver *drv;
@@ -899,7 +899,7 @@ void bdrv_info(void) @@ -899,7 +899,7 @@ void bdrv_info(void)
899 } 899 }
900 } 900 }
901 901
902 -void bdrv_get_backing_filename(BlockDriverState *bs, 902 +void bdrv_get_backing_filename(BlockDriverState *bs,
903 char *filename, int filename_size) 903 char *filename, int filename_size)
904 { 904 {
905 if (!bs->backing_hd) { 905 if (!bs->backing_hd) {
@@ -909,7 +909,7 @@ void bdrv_get_backing_filename(BlockDriverState *bs, @@ -909,7 +909,7 @@ void bdrv_get_backing_filename(BlockDriverState *bs,
909 } 909 }
910 } 910 }
911 911
912 -int bdrv_write_compressed(BlockDriverState *bs, int64_t sector_num, 912 +int bdrv_write_compressed(BlockDriverState *bs, int64_t sector_num,
913 const uint8_t *buf, int nb_sectors) 913 const uint8_t *buf, int nb_sectors)
914 { 914 {
915 BlockDriver *drv = bs->drv; 915 BlockDriver *drv = bs->drv;
@@ -919,7 +919,7 @@ int bdrv_write_compressed(BlockDriverState *bs, int64_t sector_num, @@ -919,7 +919,7 @@ int bdrv_write_compressed(BlockDriverState *bs, int64_t sector_num,
919 return -ENOTSUP; 919 return -ENOTSUP;
920 return drv->bdrv_write_compressed(bs, sector_num, buf, nb_sectors); 920 return drv->bdrv_write_compressed(bs, sector_num, buf, nb_sectors);
921 } 921 }
922 - 922 +
923 int bdrv_get_info(BlockDriverState *bs, BlockDriverInfo *bdi) 923 int bdrv_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
924 { 924 {
925 BlockDriver *drv = bs->drv; 925 BlockDriver *drv = bs->drv;
@@ -934,7 +934,7 @@ int bdrv_get_info(BlockDriverState *bs, BlockDriverInfo *bdi) @@ -934,7 +934,7 @@ int bdrv_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
934 /**************************************************************/ 934 /**************************************************************/
935 /* handling of snapshots */ 935 /* handling of snapshots */
936 936
937 -int bdrv_snapshot_create(BlockDriverState *bs, 937 +int bdrv_snapshot_create(BlockDriverState *bs,
938 QEMUSnapshotInfo *sn_info) 938 QEMUSnapshotInfo *sn_info)
939 { 939 {
940 BlockDriver *drv = bs->drv; 940 BlockDriver *drv = bs->drv;
@@ -945,7 +945,7 @@ int bdrv_snapshot_create(BlockDriverState *bs, @@ -945,7 +945,7 @@ int bdrv_snapshot_create(BlockDriverState *bs,
945 return drv->bdrv_snapshot_create(bs, sn_info); 945 return drv->bdrv_snapshot_create(bs, sn_info);
946 } 946 }
947 947
948 -int bdrv_snapshot_goto(BlockDriverState *bs, 948 +int bdrv_snapshot_goto(BlockDriverState *bs,
949 const char *snapshot_id) 949 const char *snapshot_id)
950 { 950 {
951 BlockDriver *drv = bs->drv; 951 BlockDriver *drv = bs->drv;
@@ -966,7 +966,7 @@ int bdrv_snapshot_delete(BlockDriverState *bs, const char *snapshot_id) @@ -966,7 +966,7 @@ int bdrv_snapshot_delete(BlockDriverState *bs, const char *snapshot_id)
966 return drv->bdrv_snapshot_delete(bs, snapshot_id); 966 return drv->bdrv_snapshot_delete(bs, snapshot_id);
967 } 967 }
968 968
969 -int bdrv_snapshot_list(BlockDriverState *bs, 969 +int bdrv_snapshot_list(BlockDriverState *bs,
970 QEMUSnapshotInfo **psn_info) 970 QEMUSnapshotInfo **psn_info)
971 { 971 {
972 BlockDriver *drv = bs->drv; 972 BlockDriver *drv = bs->drv;
@@ -991,12 +991,12 @@ char *get_human_readable_size(char *buf, int buf_size, int64_t size) @@ -991,12 +991,12 @@ char *get_human_readable_size(char *buf, int buf_size, int64_t size)
991 base = 1024; 991 base = 1024;
992 for(i = 0; i < NB_SUFFIXES; i++) { 992 for(i = 0; i < NB_SUFFIXES; i++) {
993 if (size < (10 * base)) { 993 if (size < (10 * base)) {
994 - snprintf(buf, buf_size, "%0.1f%c", 994 + snprintf(buf, buf_size, "%0.1f%c",
995 (double)size / base, 995 (double)size / base,
996 suffixes[i]); 996 suffixes[i]);
997 break; 997 break;
998 } else if (size < (1000 * base) || i == (NB_SUFFIXES - 1)) { 998 } else if (size < (1000 * base) || i == (NB_SUFFIXES - 1)) {
999 - snprintf(buf, buf_size, "%" PRId64 "%c", 999 + snprintf(buf, buf_size, "%" PRId64 "%c",
1000 ((size + (base >> 1)) / base), 1000 ((size + (base >> 1)) / base),
1001 suffixes[i]); 1001 suffixes[i]);
1002 break; 1002 break;
@@ -1019,8 +1019,8 @@ char *bdrv_snapshot_dump(char *buf, int buf_size, QEMUSnapshotInfo *sn) @@ -1019,8 +1019,8 @@ char *bdrv_snapshot_dump(char *buf, int buf_size, QEMUSnapshotInfo *sn)
1019 int64_t secs; 1019 int64_t secs;
1020 1020
1021 if (!sn) { 1021 if (!sn) {
1022 - snprintf(buf, buf_size,  
1023 - "%-10s%-20s%7s%20s%15s", 1022 + snprintf(buf, buf_size,
  1023 + "%-10s%-20s%7s%20s%15s",
1024 "ID", "TAG", "VM SIZE", "DATE", "VM CLOCK"); 1024 "ID", "TAG", "VM SIZE", "DATE", "VM CLOCK");
1025 } else { 1025 } else {
1026 ti = sn->date_sec; 1026 ti = sn->date_sec;
@@ -1038,10 +1038,10 @@ char *bdrv_snapshot_dump(char *buf, int buf_size, QEMUSnapshotInfo *sn) @@ -1038,10 +1038,10 @@ char *bdrv_snapshot_dump(char *buf, int buf_size, QEMUSnapshotInfo *sn)
1038 "%02d:%02d:%02d.%03d", 1038 "%02d:%02d:%02d.%03d",
1039 (int)(secs / 3600), 1039 (int)(secs / 3600),
1040 (int)((secs / 60) % 60), 1040 (int)((secs / 60) % 60),
1041 - (int)(secs % 60), 1041 + (int)(secs % 60),
1042 (int)((sn->vm_clock_nsec / 1000000) % 1000)); 1042 (int)((sn->vm_clock_nsec / 1000000) % 1000));
1043 snprintf(buf, buf_size, 1043 snprintf(buf, buf_size,
1044 - "%-10s%-20s%7s%20s%15s", 1044 + "%-10s%-20s%7s%20s%15s",
1045 sn->id_str, sn->name, 1045 sn->id_str, sn->name,
1046 get_human_readable_size(buf1, sizeof(buf1), sn->vm_state_size), 1046 get_human_readable_size(buf1, sizeof(buf1), sn->vm_state_size),
1047 date_buf, 1047 date_buf,
@@ -1062,7 +1062,7 @@ BlockDriverAIOCB *bdrv_aio_read(BlockDriverState *bs, int64_t sector_num, @@ -1062,7 +1062,7 @@ BlockDriverAIOCB *bdrv_aio_read(BlockDriverState *bs, int64_t sector_num,
1062 1062
1063 if (!drv) 1063 if (!drv)
1064 return NULL; 1064 return NULL;
1065 - 1065 +
1066 /* XXX: we assume that nb_sectors == 0 is suppored by the async read */ 1066 /* XXX: we assume that nb_sectors == 0 is suppored by the async read */
1067 if (sector_num == 0 && bs->boot_sector_enabled && nb_sectors > 0) { 1067 if (sector_num == 0 && bs->boot_sector_enabled && nb_sectors > 0) {
1068 memcpy(buf, bs->boot_sector_data, 512); 1068 memcpy(buf, bs->boot_sector_data, 512);
@@ -1085,7 +1085,7 @@ BlockDriverAIOCB *bdrv_aio_write(BlockDriverState *bs, int64_t sector_num, @@ -1085,7 +1085,7 @@ BlockDriverAIOCB *bdrv_aio_write(BlockDriverState *bs, int64_t sector_num,
1085 if (bs->read_only) 1085 if (bs->read_only)
1086 return NULL; 1086 return NULL;
1087 if (sector_num == 0 && bs->boot_sector_enabled && nb_sectors > 0) { 1087 if (sector_num == 0 && bs->boot_sector_enabled && nb_sectors > 0) {
1088 - memcpy(bs->boot_sector_data, buf, 512); 1088 + memcpy(bs->boot_sector_data, buf, 512);
1089 } 1089 }
1090 1090
1091 return drv->bdrv_aio_write(bs, sector_num, buf, nb_sectors, cb, opaque); 1091 return drv->bdrv_aio_write(bs, sector_num, buf, nb_sectors, cb, opaque);
@@ -1184,7 +1184,7 @@ static void bdrv_rw_em_cb(void *opaque, int ret) @@ -1184,7 +1184,7 @@ static void bdrv_rw_em_cb(void *opaque, int ret)
1184 1184
1185 #define NOT_DONE 0x7fffffff 1185 #define NOT_DONE 0x7fffffff
1186 1186
1187 -static int bdrv_read_em(BlockDriverState *bs, int64_t sector_num, 1187 +static int bdrv_read_em(BlockDriverState *bs, int64_t sector_num,
1188 uint8_t *buf, int nb_sectors) 1188 uint8_t *buf, int nb_sectors)
1189 { 1189 {
1190 int async_ret; 1190 int async_ret;
@@ -1192,7 +1192,7 @@ static int bdrv_read_em(BlockDriverState *bs, int64_t sector_num, @@ -1192,7 +1192,7 @@ static int bdrv_read_em(BlockDriverState *bs, int64_t sector_num,
1192 1192
1193 async_ret = NOT_DONE; 1193 async_ret = NOT_DONE;
1194 qemu_aio_wait_start(); 1194 qemu_aio_wait_start();
1195 - acb = bdrv_aio_read(bs, sector_num, buf, nb_sectors, 1195 + acb = bdrv_aio_read(bs, sector_num, buf, nb_sectors,
1196 bdrv_rw_em_cb, &async_ret); 1196 bdrv_rw_em_cb, &async_ret);
1197 if (acb == NULL) { 1197 if (acb == NULL) {
1198 qemu_aio_wait_end(); 1198 qemu_aio_wait_end();
@@ -1213,7 +1213,7 @@ static int bdrv_write_em(BlockDriverState *bs, int64_t sector_num, @@ -1213,7 +1213,7 @@ static int bdrv_write_em(BlockDriverState *bs, int64_t sector_num,
1213 1213
1214 async_ret = NOT_DONE; 1214 async_ret = NOT_DONE;
1215 qemu_aio_wait_start(); 1215 qemu_aio_wait_start();
1216 - acb = bdrv_aio_write(bs, sector_num, buf, nb_sectors, 1216 + acb = bdrv_aio_write(bs, sector_num, buf, nb_sectors,
1217 bdrv_rw_em_cb, &async_ret); 1217 bdrv_rw_em_cb, &async_ret);
1218 if (acb == NULL) { 1218 if (acb == NULL) {
1219 qemu_aio_wait_end(); 1219 qemu_aio_wait_end();
@@ -1293,7 +1293,7 @@ int bdrv_is_inserted(BlockDriverState *bs) @@ -1293,7 +1293,7 @@ int bdrv_is_inserted(BlockDriverState *bs)
1293 1293
1294 /** 1294 /**
1295 * Return TRUE if the media changed since the last call to this 1295 * Return TRUE if the media changed since the last call to this
1296 - * function. It is currently only used for floppy disks 1296 + * function. It is currently only used for floppy disks
1297 */ 1297 */
1298 int bdrv_media_changed(BlockDriverState *bs) 1298 int bdrv_media_changed(BlockDriverState *bs)
1299 { 1299 {
block_int.h
1 /* 1 /*
2 * QEMU System Emulator block driver 2 * QEMU System Emulator block driver
3 - * 3 + *
4 * Copyright (c) 2003 Fabrice Bellard 4 * Copyright (c) 2003 Fabrice Bellard
5 - * 5 + *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy 6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal 7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights 8 * in the Software without restriction, including without limitation the rights
@@ -29,12 +29,12 @@ struct BlockDriver { @@ -29,12 +29,12 @@ struct BlockDriver {
29 int instance_size; 29 int instance_size;
30 int (*bdrv_probe)(const uint8_t *buf, int buf_size, const char *filename); 30 int (*bdrv_probe)(const uint8_t *buf, int buf_size, const char *filename);
31 int (*bdrv_open)(BlockDriverState *bs, const char *filename, int flags); 31 int (*bdrv_open)(BlockDriverState *bs, const char *filename, int flags);
32 - int (*bdrv_read)(BlockDriverState *bs, int64_t sector_num, 32 + int (*bdrv_read)(BlockDriverState *bs, int64_t sector_num,
33 uint8_t *buf, int nb_sectors); 33 uint8_t *buf, int nb_sectors);
34 - int (*bdrv_write)(BlockDriverState *bs, int64_t sector_num, 34 + int (*bdrv_write)(BlockDriverState *bs, int64_t sector_num,
35 const uint8_t *buf, int nb_sectors); 35 const uint8_t *buf, int nb_sectors);
36 void (*bdrv_close)(BlockDriverState *bs); 36 void (*bdrv_close)(BlockDriverState *bs);
37 - int (*bdrv_create)(const char *filename, int64_t total_sectors, 37 + int (*bdrv_create)(const char *filename, int64_t total_sectors,
38 const char *backing_file, int flags); 38 const char *backing_file, int flags);
39 void (*bdrv_flush)(BlockDriverState *bs); 39 void (*bdrv_flush)(BlockDriverState *bs);
40 int (*bdrv_is_allocated)(BlockDriverState *bs, int64_t sector_num, 40 int (*bdrv_is_allocated)(BlockDriverState *bs, int64_t sector_num,
@@ -52,21 +52,21 @@ struct BlockDriver { @@ -52,21 +52,21 @@ struct BlockDriver {
52 int aiocb_size; 52 int aiocb_size;
53 53
54 const char *protocol_name; 54 const char *protocol_name;
55 - int (*bdrv_pread)(BlockDriverState *bs, int64_t offset, 55 + int (*bdrv_pread)(BlockDriverState *bs, int64_t offset,
56 uint8_t *buf, int count); 56 uint8_t *buf, int count);
57 - int (*bdrv_pwrite)(BlockDriverState *bs, int64_t offset, 57 + int (*bdrv_pwrite)(BlockDriverState *bs, int64_t offset,
58 const uint8_t *buf, int count); 58 const uint8_t *buf, int count);
59 int (*bdrv_truncate)(BlockDriverState *bs, int64_t offset); 59 int (*bdrv_truncate)(BlockDriverState *bs, int64_t offset);
60 int64_t (*bdrv_getlength)(BlockDriverState *bs); 60 int64_t (*bdrv_getlength)(BlockDriverState *bs);
61 - int (*bdrv_write_compressed)(BlockDriverState *bs, int64_t sector_num, 61 + int (*bdrv_write_compressed)(BlockDriverState *bs, int64_t sector_num,
62 const uint8_t *buf, int nb_sectors); 62 const uint8_t *buf, int nb_sectors);
63 63
64 - int (*bdrv_snapshot_create)(BlockDriverState *bs, 64 + int (*bdrv_snapshot_create)(BlockDriverState *bs,
65 QEMUSnapshotInfo *sn_info); 65 QEMUSnapshotInfo *sn_info);
66 - int (*bdrv_snapshot_goto)(BlockDriverState *bs, 66 + int (*bdrv_snapshot_goto)(BlockDriverState *bs,
67 const char *snapshot_id); 67 const char *snapshot_id);
68 int (*bdrv_snapshot_delete)(BlockDriverState *bs, const char *snapshot_id); 68 int (*bdrv_snapshot_delete)(BlockDriverState *bs, const char *snapshot_id);
69 - int (*bdrv_snapshot_list)(BlockDriverState *bs, 69 + int (*bdrv_snapshot_list)(BlockDriverState *bs,
70 QEMUSnapshotInfo **psn_info); 70 QEMUSnapshotInfo **psn_info);
71 int (*bdrv_get_info)(BlockDriverState *bs, BlockDriverInfo *bdi); 71 int (*bdrv_get_info)(BlockDriverState *bs, BlockDriverInfo *bdi);
72 72
@@ -75,7 +75,7 @@ struct BlockDriver { @@ -75,7 +75,7 @@ struct BlockDriver {
75 int (*bdrv_media_changed)(BlockDriverState *bs); 75 int (*bdrv_media_changed)(BlockDriverState *bs);
76 int (*bdrv_eject)(BlockDriverState *bs, int eject_flag); 76 int (*bdrv_eject)(BlockDriverState *bs, int eject_flag);
77 int (*bdrv_set_locked)(BlockDriverState *bs, int locked); 77 int (*bdrv_set_locked)(BlockDriverState *bs, int locked);
78 - 78 +
79 BlockDriverAIOCB *free_aiocb; 79 BlockDriverAIOCB *free_aiocb;
80 struct BlockDriver *next; 80 struct BlockDriver *next;
81 }; 81 };
@@ -107,7 +107,7 @@ struct BlockDriverState { @@ -107,7 +107,7 @@ struct BlockDriverState {
107 /* async read/write emulation */ 107 /* async read/write emulation */
108 108
109 void *sync_aiocb; 109 void *sync_aiocb;
110 - 110 +
111 /* NOTE: the following infos are only hints for real hardware 111 /* NOTE: the following infos are only hints for real hardware
112 drivers. They are not used by the block driver */ 112 drivers. They are not used by the block driver */
113 int cyls, heads, secs, translation; 113 int cyls, heads, secs, translation;
@@ -48,12 +48,12 @@ static inline uint16_t bswap16(uint16_t x) @@ -48,12 +48,12 @@ static inline uint16_t bswap16(uint16_t x)
48 return bswap_16(x); 48 return bswap_16(x);
49 } 49 }
50 50
51 -static inline uint32_t bswap32(uint32_t x) 51 +static inline uint32_t bswap32(uint32_t x)
52 { 52 {
53 return bswap_32(x); 53 return bswap_32(x);
54 } 54 }
55 55
56 -static inline uint64_t bswap64(uint64_t x) 56 +static inline uint64_t bswap64(uint64_t x)
57 { 57 {
58 return bswap_64(x); 58 return bswap_64(x);
59 } 59 }
1 /* 1 /*
2 * QEMU Cocoa display driver 2 * QEMU Cocoa display driver
3 - * 3 + *
4 * Copyright (c) 2005 Pierre d'Herbemont 4 * Copyright (c) 2005 Pierre d'Herbemont
5 * many code/inspiration from SDL 1.2 code (LGPL) 5 * many code/inspiration from SDL 1.2 code (LGPL)
6 - * 6 + *
7 * Permission is hereby granted, free of charge, to any person obtaining a copy 7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal 8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights 9 * in the Software without restriction, including without limitation the rights
@@ -23,7 +23,7 @@ @@ -23,7 +23,7 @@
23 * THE SOFTWARE. 23 * THE SOFTWARE.
24 */ 24 */
25 /* 25 /*
26 - Todo : x miniaturize window 26 + Todo : x miniaturize window
27 x center the window 27 x center the window
28 - save window position 28 - save window position
29 - handle keyboard event 29 - handle keyboard event
@@ -84,7 +84,7 @@ static void cocoa_update(DisplayState *ds, int x, int y, int w, int h) @@ -84,7 +84,7 @@ static void cocoa_update(DisplayState *ds, int x, int y, int w, int h)
84 MacSetRectRgn (temp, x, y, 84 MacSetRectRgn (temp, x, y,
85 x + w, y + h); 85 x + w, y + h);
86 MacUnionRgn (dirty, temp, dirty); 86 MacUnionRgn (dirty, temp, dirty);
87 - 87 +
88 /* Flush the dirty region */ 88 /* Flush the dirty region */
89 QDFlushPortBuffer ( [ qd_view qdPort ], dirty ); 89 QDFlushPortBuffer ( [ qd_view qdPort ], dirty );
90 DisposeRgn (dirty); 90 DisposeRgn (dirty);
@@ -102,9 +102,9 @@ static void cocoa_resize(DisplayState *ds, int w, int h) @@ -102,9 +102,9 @@ static void cocoa_resize(DisplayState *ds, int w, int h)
102 static void *screen_pixels; 102 static void *screen_pixels;
103 static int screen_pitch; 103 static int screen_pitch;
104 NSRect contentRect; 104 NSRect contentRect;
105 - 105 +
106 //printf("resizing to %d %d\n", w, h); 106 //printf("resizing to %d %d\n", w, h);
107 - 107 +
108 contentRect = NSMakeRect (0, 0, w, h); 108 contentRect = NSMakeRect (0, 0, w, h);
109 if(window) 109 if(window)
110 { 110 {
@@ -119,44 +119,44 @@ static void cocoa_resize(DisplayState *ds, int w, int h) @@ -119,44 +119,44 @@ static void cocoa_resize(DisplayState *ds, int w, int h)
119 fprintf(stderr, "(cocoa) can't create window\n"); 119 fprintf(stderr, "(cocoa) can't create window\n");
120 exit(1); 120 exit(1);
121 } 121 }
122 - 122 +
123 if(qd_view) 123 if(qd_view)
124 [qd_view release]; 124 [qd_view release];
125 - 125 +
126 qd_view = [ [ NSQuickDrawView alloc ] initWithFrame:contentRect ]; 126 qd_view = [ [ NSQuickDrawView alloc ] initWithFrame:contentRect ];
127 - 127 +
128 if(!qd_view) 128 if(!qd_view)
129 { 129 {
130 fprintf(stderr, "(cocoa) can't create qd_view\n"); 130 fprintf(stderr, "(cocoa) can't create qd_view\n");
131 exit(1); 131 exit(1);
132 } 132 }
133 - 133 +
134 [ window setAcceptsMouseMovedEvents:YES ]; 134 [ window setAcceptsMouseMovedEvents:YES ];
135 [ window setTitle:@"Qemu" ]; 135 [ window setTitle:@"Qemu" ];
136 [ window setReleasedWhenClosed:NO ]; 136 [ window setReleasedWhenClosed:NO ];
137 - 137 +
138 /* Set screen to black */ 138 /* Set screen to black */
139 [ window setBackgroundColor: [NSColor blackColor] ]; 139 [ window setBackgroundColor: [NSColor blackColor] ];
140 - 140 +
141 /* set window position */ 141 /* set window position */
142 [ window center ]; 142 [ window center ];
143 - 143 +
144 [ qd_view setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable ]; 144 [ qd_view setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable ];
145 [ [ window contentView ] addSubview:qd_view ]; 145 [ [ window contentView ] addSubview:qd_view ];
146 [ qd_view release ]; 146 [ qd_view release ];
147 [ window makeKeyAndOrderFront:nil ]; 147 [ window makeKeyAndOrderFront:nil ];
148 - 148 +
149 /* Careful here, the window seems to have to be onscreen to do that */ 149 /* Careful here, the window seems to have to be onscreen to do that */
150 LockPortBits ( [ qd_view qdPort ] ); 150 LockPortBits ( [ qd_view qdPort ] );
151 screen_pixels = GetPixBaseAddr ( GetPortPixMap ( [ qd_view qdPort ] ) ); 151 screen_pixels = GetPixBaseAddr ( GetPortPixMap ( [ qd_view qdPort ] ) );
152 screen_pitch = GetPixRowBytes ( GetPortPixMap ( [ qd_view qdPort ] ) ); 152 screen_pitch = GetPixRowBytes ( GetPortPixMap ( [ qd_view qdPort ] ) );
153 UnlockPortBits ( [ qd_view qdPort ] ); 153 UnlockPortBits ( [ qd_view qdPort ] );
154 - {  
155 - int vOffset = [ window frame ].size.height - 154 + {
  155 + int vOffset = [ window frame ].size.height -
156 [ qd_view frame ].size.height - [ qd_view frame ].origin.y; 156 [ qd_view frame ].size.height - [ qd_view frame ].origin.y;
157 - 157 +
158 int hOffset = [ qd_view frame ].origin.x; 158 int hOffset = [ qd_view frame ].origin.x;
159 - 159 +
160 screen_pixels += (vOffset * screen_pitch) + hOffset * (device_bpp/8); 160 screen_pixels += (vOffset * screen_pitch) + hOffset * (device_bpp/8);
161 } 161 }
162 ds->data = screen_pixels; 162 ds->data = screen_pixels;
@@ -310,38 +310,38 @@ int keymap[] = @@ -310,38 +310,38 @@ int keymap[] =
310 208,// 125 0x7D 0xd0 E0,50 D ARROW QZ_DOWN 310 208,// 125 0x7D 0xd0 E0,50 D ARROW QZ_DOWN
311 200,// 126 0x7E 0xc8 E0,48 U ARROW QZ_UP 311 200,// 126 0x7E 0xc8 E0,48 U ARROW QZ_UP
312 /* completed according to http://www.libsdl.org/cgi/cvsweb.cgi/SDL12/src/video/quartz/SDL_QuartzKeys.h?rev=1.6&content-type=text/x-cvsweb-markup */ 312 /* completed according to http://www.libsdl.org/cgi/cvsweb.cgi/SDL12/src/video/quartz/SDL_QuartzKeys.h?rev=1.6&content-type=text/x-cvsweb-markup */
313 - 313 +
314 /* Aditional 104 Key XP-Keyboard Scancodes from http://www.computer-engineering.org/ps2keyboard/scancodes1.html */ 314 /* Aditional 104 Key XP-Keyboard Scancodes from http://www.computer-engineering.org/ps2keyboard/scancodes1.html */
315 /* 315 /*
316 - 219 // 0xdb e0,5b L GUI  
317 - 220 // 0xdc e0,5c R GUI  
318 - 221 // 0xdd e0,5d APPS  
319 - // E0,2A,E0,37 PRNT SCRN  
320 - // E1,1D,45,E1,9D,C5 PAUSE  
321 - 83 // 0x53 0x53 KP .  
322 -// ACPI Scan Codes  
323 - 222 // 0xde E0, 5E Power  
324 - 223 // 0xdf E0, 5F Sleep  
325 - 227 // 0xe3 E0, 63 Wake  
326 -// Windows Multimedia Scan Codes  
327 - 153 // 0x99 E0, 19 Next Track  
328 - 144 // 0x90 E0, 10 Previous Track  
329 - 164 // 0xa4 E0, 24 Stop  
330 - 162 // 0xa2 E0, 22 Play/Pause  
331 - 160 // 0xa0 E0, 20 Mute  
332 - 176 // 0xb0 E0, 30 Volume Up  
333 - 174 // 0xae E0, 2E Volume Down  
334 - 237 // 0xed E0, 6D Media Select  
335 - 236 // 0xec E0, 6C E-Mail  
336 - 161 // 0xa1 E0, 21 Calculator  
337 - 235 // 0xeb E0, 6B My Computer  
338 - 229 // 0xe5 E0, 65 WWW Search  
339 - 178 // 0xb2 E0, 32 WWW Home  
340 - 234 // 0xea E0, 6A WWW Back  
341 - 233 // 0xe9 E0, 69 WWW Forward  
342 - 232 // 0xe8 E0, 68 WWW Stop  
343 - 231 // 0xe7 E0, 67 WWW Refresh  
344 - 230 // 0xe6 E0, 66 WWW Favorites 316 + 219 // 0xdb e0,5b L GUI
  317 + 220 // 0xdc e0,5c R GUI
  318 + 221 // 0xdd e0,5d APPS
  319 + // E0,2A,E0,37 PRNT SCRN
  320 + // E1,1D,45,E1,9D,C5 PAUSE
  321 + 83 // 0x53 0x53 KP .
  322 +// ACPI Scan Codes
  323 + 222 // 0xde E0, 5E Power
  324 + 223 // 0xdf E0, 5F Sleep
  325 + 227 // 0xe3 E0, 63 Wake
  326 +// Windows Multimedia Scan Codes
  327 + 153 // 0x99 E0, 19 Next Track
  328 + 144 // 0x90 E0, 10 Previous Track
  329 + 164 // 0xa4 E0, 24 Stop
  330 + 162 // 0xa2 E0, 22 Play/Pause
  331 + 160 // 0xa0 E0, 20 Mute
  332 + 176 // 0xb0 E0, 30 Volume Up
  333 + 174 // 0xae E0, 2E Volume Down
  334 + 237 // 0xed E0, 6D Media Select
  335 + 236 // 0xec E0, 6C E-Mail
  336 + 161 // 0xa1 E0, 21 Calculator
  337 + 235 // 0xeb E0, 6B My Computer
  338 + 229 // 0xe5 E0, 65 WWW Search
  339 + 178 // 0xb2 E0, 32 WWW Home
  340 + 234 // 0xea E0, 6A WWW Back
  341 + 233 // 0xe9 E0, 69 WWW Forward
  342 + 232 // 0xe8 E0, 68 WWW Stop
  343 + 231 // 0xe7 E0, 67 WWW Refresh
  344 + 230 // 0xe6 E0, 66 WWW Favorites
345 */ 345 */
346 }; 346 };
347 347
@@ -366,10 +366,10 @@ static void cocoa_refresh(DisplayState *ds) @@ -366,10 +366,10 @@ static void cocoa_refresh(DisplayState *ds)
366 NSDate *distantPast; 366 NSDate *distantPast;
367 NSEvent *event; 367 NSEvent *event;
368 NSAutoreleasePool *pool; 368 NSAutoreleasePool *pool;
369 - 369 +
370 pool = [ [ NSAutoreleasePool alloc ] init ]; 370 pool = [ [ NSAutoreleasePool alloc ] init ];
371 distantPast = [ NSDate distantPast ]; 371 distantPast = [ NSDate distantPast ];
372 - 372 +
373 vga_hw_update(); 373 vga_hw_update();
374 374
375 do { 375 do {
@@ -415,8 +415,8 @@ static void cocoa_refresh(DisplayState *ds) @@ -415,8 +415,8 @@ static void cocoa_refresh(DisplayState *ds)
415 415
416 case NSKeyDown: 416 case NSKeyDown:
417 { 417 {
418 - int keycode = cocoa_keycode_to_qemu([event keyCode]);  
419 - 418 + int keycode = cocoa_keycode_to_qemu([event keyCode]);
  419 +
420 /* handle command Key Combos */ 420 /* handle command Key Combos */
421 if ([event modifierFlags] & NSCommandKeyMask) { 421 if ([event modifierFlags] & NSCommandKeyMask) {
422 switch ([event keyCode]) { 422 switch ([event keyCode]) {
@@ -427,7 +427,7 @@ static void cocoa_refresh(DisplayState *ds) @@ -427,7 +427,7 @@ static void cocoa_refresh(DisplayState *ds)
427 return; 427 return;
428 } 428 }
429 } 429 }
430 - 430 +
431 /* handle control + alt Key Combos */ 431 /* handle control + alt Key Combos */
432 if (([event modifierFlags] & NSControlKeyMask) && ([event modifierFlags] & NSAlternateKeyMask)) { 432 if (([event modifierFlags] & NSControlKeyMask) && ([event modifierFlags] & NSAlternateKeyMask)) {
433 switch (keycode) { 433 switch (keycode) {
@@ -482,10 +482,10 @@ static void cocoa_refresh(DisplayState *ds) @@ -482,10 +482,10 @@ static void cocoa_refresh(DisplayState *ds)
482 } 482 }
483 } 483 }
484 break; 484 break;
485 - 485 +
486 case NSKeyUp: 486 case NSKeyUp:
487 { 487 {
488 - int keycode = cocoa_keycode_to_qemu([event keyCode]); 488 + int keycode = cocoa_keycode_to_qemu([event keyCode]);
489 if (is_graphic_console()) { 489 if (is_graphic_console()) {
490 if (keycode & 0x80) 490 if (keycode & 0x80)
491 kbd_put_keycode(0xe0); 491 kbd_put_keycode(0xe0);
@@ -493,7 +493,7 @@ static void cocoa_refresh(DisplayState *ds) @@ -493,7 +493,7 @@ static void cocoa_refresh(DisplayState *ds)
493 } 493 }
494 } 494 }
495 break; 495 break;
496 - 496 +
497 case NSMouseMoved: 497 case NSMouseMoved:
498 if (grab) { 498 if (grab) {
499 int dx = [event deltaX]; 499 int dx = [event deltaX];
@@ -503,11 +503,11 @@ static void cocoa_refresh(DisplayState *ds) @@ -503,11 +503,11 @@ static void cocoa_refresh(DisplayState *ds)
503 kbd_mouse_event(dx, dy, dz, buttons); 503 kbd_mouse_event(dx, dy, dz, buttons);
504 } 504 }
505 break; 505 break;
506 - 506 +
507 case NSLeftMouseDown: 507 case NSLeftMouseDown:
508 if (grab) { 508 if (grab) {
509 int buttons = 0; 509 int buttons = 0;
510 - 510 +
511 /* leftclick+command simulates rightclick */ 511 /* leftclick+command simulates rightclick */
512 if ([event modifierFlags] & NSCommandKeyMask) { 512 if ([event modifierFlags] & NSCommandKeyMask) {
513 buttons |= MOUSE_EVENT_RBUTTON; 513 buttons |= MOUSE_EVENT_RBUTTON;
@@ -519,7 +519,7 @@ static void cocoa_refresh(DisplayState *ds) @@ -519,7 +519,7 @@ static void cocoa_refresh(DisplayState *ds)
519 [NSApp sendEvent: event]; 519 [NSApp sendEvent: event];
520 } 520 }
521 break; 521 break;
522 - 522 +
523 case NSLeftMouseDragged: 523 case NSLeftMouseDragged:
524 if (grab) { 524 if (grab) {
525 int dx = [event deltaX]; 525 int dx = [event deltaX];
@@ -534,7 +534,7 @@ static void cocoa_refresh(DisplayState *ds) @@ -534,7 +534,7 @@ static void cocoa_refresh(DisplayState *ds)
534 kbd_mouse_event(dx, dy, dz, buttons); 534 kbd_mouse_event(dx, dy, dz, buttons);
535 } 535 }
536 break; 536 break;
537 - 537 +
538 case NSLeftMouseUp: 538 case NSLeftMouseUp:
539 if (grab) { 539 if (grab) {
540 kbd_mouse_event(0, 0, 0, 0); 540 kbd_mouse_event(0, 0, 0, 0);
@@ -546,18 +546,18 @@ static void cocoa_refresh(DisplayState *ds) @@ -546,18 +546,18 @@ static void cocoa_refresh(DisplayState *ds)
546 //[NSApp sendEvent: event]; 546 //[NSApp sendEvent: event];
547 } 547 }
548 break; 548 break;
549 - 549 +
550 case NSRightMouseDown: 550 case NSRightMouseDown:
551 if (grab) { 551 if (grab) {
552 int buttons = 0; 552 int buttons = 0;
553 - 553 +
554 buttons |= MOUSE_EVENT_RBUTTON; 554 buttons |= MOUSE_EVENT_RBUTTON;
555 kbd_mouse_event(0, 0, 0, buttons); 555 kbd_mouse_event(0, 0, 0, buttons);
556 } else { 556 } else {
557 [NSApp sendEvent: event]; 557 [NSApp sendEvent: event];
558 } 558 }
559 break; 559 break;
560 - 560 +
561 case NSRightMouseDragged: 561 case NSRightMouseDragged:
562 if (grab) { 562 if (grab) {
563 int dx = [event deltaX]; 563 int dx = [event deltaX];
@@ -568,7 +568,7 @@ static void cocoa_refresh(DisplayState *ds) @@ -568,7 +568,7 @@ static void cocoa_refresh(DisplayState *ds)
568 kbd_mouse_event(dx, dy, dz, buttons); 568 kbd_mouse_event(dx, dy, dz, buttons);
569 } 569 }
570 break; 570 break;
571 - 571 +
572 case NSRightMouseUp: 572 case NSRightMouseUp:
573 if (grab) { 573 if (grab) {
574 kbd_mouse_event(0, 0, 0, 0); 574 kbd_mouse_event(0, 0, 0, 0);
@@ -576,7 +576,7 @@ static void cocoa_refresh(DisplayState *ds) @@ -576,7 +576,7 @@ static void cocoa_refresh(DisplayState *ds)
576 [NSApp sendEvent: event]; 576 [NSApp sendEvent: event];
577 } 577 }
578 break; 578 break;
579 - 579 +
580 case NSOtherMouseDragged: 580 case NSOtherMouseDragged:
581 if (grab) { 581 if (grab) {
582 int dx = [event deltaX]; 582 int dx = [event deltaX];
@@ -587,7 +587,7 @@ static void cocoa_refresh(DisplayState *ds) @@ -587,7 +587,7 @@ static void cocoa_refresh(DisplayState *ds)
587 kbd_mouse_event(dx, dy, dz, buttons); 587 kbd_mouse_event(dx, dy, dz, buttons);
588 } 588 }
589 break; 589 break;
590 - 590 +
591 case NSOtherMouseDown: 591 case NSOtherMouseDown:
592 if (grab) { 592 if (grab) {
593 int buttons = 0; 593 int buttons = 0;
@@ -597,7 +597,7 @@ static void cocoa_refresh(DisplayState *ds) @@ -597,7 +597,7 @@ static void cocoa_refresh(DisplayState *ds)
597 [NSApp sendEvent:event]; 597 [NSApp sendEvent:event];
598 } 598 }
599 break; 599 break;
600 - 600 +
601 case NSOtherMouseUp: 601 case NSOtherMouseUp:
602 if (grab) { 602 if (grab) {
603 kbd_mouse_event(0, 0, 0, 0); 603 kbd_mouse_event(0, 0, 0, 0);
@@ -605,14 +605,14 @@ static void cocoa_refresh(DisplayState *ds) @@ -605,14 +605,14 @@ static void cocoa_refresh(DisplayState *ds)
605 [NSApp sendEvent: event]; 605 [NSApp sendEvent: event];
606 } 606 }
607 break; 607 break;
608 - 608 +
609 case NSScrollWheel: 609 case NSScrollWheel:
610 if (grab) { 610 if (grab) {
611 int dz = [event deltaY]; 611 int dz = [event deltaY];
612 kbd_mouse_event(0, 0, -dz, 0); 612 kbd_mouse_event(0, 0, -dz, 0);
613 } 613 }
614 break; 614 break;
615 - 615 +
616 default: [NSApp sendEvent:event]; 616 default: [NSApp sendEvent:event];
617 } 617 }
618 } 618 }
@@ -625,7 +625,7 @@ static void cocoa_refresh(DisplayState *ds) @@ -625,7 +625,7 @@ static void cocoa_refresh(DisplayState *ds)
625 ------------------------------------------------------ 625 ------------------------------------------------------
626 */ 626 */
627 627
628 -static void cocoa_cleanup(void) 628 +static void cocoa_cleanup(void)
629 { 629 {
630 630
631 } 631 }
@@ -641,9 +641,9 @@ void cocoa_display_init(DisplayState *ds, int full_screen) @@ -641,9 +641,9 @@ void cocoa_display_init(DisplayState *ds, int full_screen)
641 ds->dpy_update = cocoa_update; 641 ds->dpy_update = cocoa_update;
642 ds->dpy_resize = cocoa_resize; 642 ds->dpy_resize = cocoa_resize;
643 ds->dpy_refresh = cocoa_refresh; 643 ds->dpy_refresh = cocoa_refresh;
644 - 644 +
645 cocoa_resize(ds, 640, 400); 645 cocoa_resize(ds, 640, 400);
646 - 646 +
647 atexit(cocoa_cleanup); 647 atexit(cocoa_cleanup);
648 } 648 }
649 649
@@ -661,17 +661,17 @@ void cocoa_display_init(DisplayState *ds, int full_screen) @@ -661,17 +661,17 @@ void cocoa_display_init(DisplayState *ds, int full_screen)
661 ------------------------------------------------------ 661 ------------------------------------------------------
662 */ 662 */
663 static void QZ_SetPortAlphaOpaque () 663 static void QZ_SetPortAlphaOpaque ()
664 -{ 664 +{
665 /* Assume 32 bit if( bpp == 32 )*/ 665 /* Assume 32 bit if( bpp == 32 )*/
666 if ( 1 ) { 666 if ( 1 ) {
667 - 667 +
668 uint32_t *pixels = (uint32_t*) current_ds.data; 668 uint32_t *pixels = (uint32_t*) current_ds.data;
669 uint32_t rowPixels = current_ds.linesize / 4; 669 uint32_t rowPixels = current_ds.linesize / 4;
670 uint32_t i, j; 670 uint32_t i, j;
671 - 671 +
672 for (i = 0; i < current_ds.height; i++) 672 for (i = 0; i < current_ds.height; i++)
673 for (j = 0; j < current_ds.width; j++) { 673 for (j = 0; j < current_ds.width; j++) {
674 - 674 +
675 pixels[ (i * rowPixels) + j ] |= 0xFF000000; 675 pixels[ (i * rowPixels) + j ] |= 0xFF000000;
676 } 676 }
677 } 677 }
@@ -680,32 +680,32 @@ static void QZ_SetPortAlphaOpaque () @@ -680,32 +680,32 @@ static void QZ_SetPortAlphaOpaque ()
680 @implementation QemuWindow 680 @implementation QemuWindow
681 - (void)miniaturize:(id)sender 681 - (void)miniaturize:(id)sender
682 { 682 {
683 - 683 +
684 /* make the alpha channel opaque so anim won't have holes in it */ 684 /* make the alpha channel opaque so anim won't have holes in it */
685 QZ_SetPortAlphaOpaque (); 685 QZ_SetPortAlphaOpaque ();
686 - 686 +
687 [ super miniaturize:sender ]; 687 [ super miniaturize:sender ];
688 - 688 +
689 } 689 }
690 - (void)display 690 - (void)display
691 -{  
692 - /* 691 +{
  692 + /*
693 This method fires just before the window deminaturizes from the Dock. 693 This method fires just before the window deminaturizes from the Dock.
694 - 694 +
695 We'll save the current visible surface, let the window manager redraw any 695 We'll save the current visible surface, let the window manager redraw any
696 - UI elements, and restore the SDL surface. This way, no expose event 696 + UI elements, and restore the SDL surface. This way, no expose event
697 is required, and the deminiaturize works perfectly. 697 is required, and the deminiaturize works perfectly.
698 */ 698 */
699 - 699 +
700 /* make sure pixels are fully opaque */ 700 /* make sure pixels are fully opaque */
701 QZ_SetPortAlphaOpaque (); 701 QZ_SetPortAlphaOpaque ();
702 - 702 +
703 /* save current visible SDL surface */ 703 /* save current visible SDL surface */
704 [ self cacheImageInRect:[ qd_view frame ] ]; 704 [ self cacheImageInRect:[ qd_view frame ] ];
705 - 705 +
706 /* let the window manager redraw controls, border, etc */ 706 /* let the window manager redraw controls, border, etc */
707 [ super display ]; 707 [ super display ];
708 - 708 +
709 /* restore visible SDL surface */ 709 /* restore visible SDL surface */
710 [ self restoreCachedImage ]; 710 [ self restoreCachedImage ];
711 } 711 }
@@ -742,13 +742,13 @@ static void QZ_SetPortAlphaOpaque () @@ -742,13 +742,13 @@ static void QZ_SetPortAlphaOpaque ()
742 if( gArgc <= 1 || strncmp (gArgv[1], "-psn", 4) == 0) 742 if( gArgc <= 1 || strncmp (gArgv[1], "-psn", 4) == 0)
743 { 743 {
744 NSOpenPanel *op = [[NSOpenPanel alloc] init]; 744 NSOpenPanel *op = [[NSOpenPanel alloc] init];
745 - 745 +
746 cocoa_resize(&current_ds, 640, 400); 746 cocoa_resize(&current_ds, 640, 400);
747 - 747 +
748 [op setPrompt:@"Boot image"]; 748 [op setPrompt:@"Boot image"];
749 - 749 +
750 [op setMessage:@"Select the disk image you want to boot.\n\nHit the \"Cancel\" button to quit"]; 750 [op setMessage:@"Select the disk image you want to boot.\n\nHit the \"Cancel\" button to quit"];
751 - 751 +
752 [op beginSheetForDirectory:nil file:nil types:[NSArray arrayWithObjects:@"img",@"iso",@"dmg",@"qcow",@"cow",@"cloop",@"vmdk",nil] 752 [op beginSheetForDirectory:nil file:nil types:[NSArray arrayWithObjects:@"img",@"iso",@"dmg",@"qcow",@"cow",@"cloop",@"vmdk",nil]
753 modalForWindow:window modalDelegate:self 753 modalForWindow:window modalDelegate:self
754 didEndSelector:@selector(openPanelDidEnd:returnCode:contextInfo:) contextInfo:NULL]; 754 didEndSelector:@selector(openPanelDidEnd:returnCode:contextInfo:) contextInfo:NULL];
@@ -774,20 +774,20 @@ static void QZ_SetPortAlphaOpaque () @@ -774,20 +774,20 @@ static void QZ_SetPortAlphaOpaque ()
774 { 774 {
775 exit(0); 775 exit(0);
776 } 776 }
777 - 777 +
778 if(returnCode == NSOKButton) 778 if(returnCode == NSOKButton)
779 { 779 {
780 char *bin = "qemu"; 780 char *bin = "qemu";
781 char *img = (char*)[ [ sheet filename ] cString]; 781 char *img = (char*)[ [ sheet filename ] cString];
782 - 782 +
783 char **argv = (char**)malloc( sizeof(char*)*3 ); 783 char **argv = (char**)malloc( sizeof(char*)*3 );
784 - 784 +
785 asprintf(&argv[0], "%s", bin); 785 asprintf(&argv[0], "%s", bin);
786 asprintf(&argv[1], "-hda"); 786 asprintf(&argv[1], "-hda");
787 asprintf(&argv[2], "%s", img); 787 asprintf(&argv[2], "%s", img);
788 - 788 +
789 printf("Using argc %d argv %s -hda %s\n", 3, bin, img); 789 printf("Using argc %d argv %s -hda %s\n", 3, bin, img);
790 - 790 +
791 [self startEmulationWithArgc:3 argv:(char**)argv]; 791 [self startEmulationWithArgc:3 argv:(char**)argv];
792 } 792 }
793 } 793 }
@@ -827,10 +827,10 @@ static void setApplicationMenu(void) @@ -827,10 +827,10 @@ static void setApplicationMenu(void)
827 NSMenuItem *menuItem; 827 NSMenuItem *menuItem;
828 NSString *title; 828 NSString *title;
829 NSString *appName; 829 NSString *appName;
830 - 830 +
831 appName = @"Qemu"; 831 appName = @"Qemu";
832 appleMenu = [[NSMenu alloc] initWithTitle:@""]; 832 appleMenu = [[NSMenu alloc] initWithTitle:@""];
833 - 833 +
834 /* Add menu items */ 834 /* Add menu items */
835 title = [@"About " stringByAppendingString:appName]; 835 title = [@"About " stringByAppendingString:appName];
836 [appleMenu addItemWithTitle:title action:@selector(orderFrontStandardAboutPanel:) keyEquivalent:@""]; 836 [appleMenu addItemWithTitle:title action:@selector(orderFrontStandardAboutPanel:) keyEquivalent:@""];
@@ -850,7 +850,7 @@ static void setApplicationMenu(void) @@ -850,7 +850,7 @@ static void setApplicationMenu(void)
850 title = [@"Quit " stringByAppendingString:appName]; 850 title = [@"Quit " stringByAppendingString:appName];
851 [appleMenu addItemWithTitle:title action:@selector(terminate:) keyEquivalent:@"q"]; 851 [appleMenu addItemWithTitle:title action:@selector(terminate:) keyEquivalent:@"q"];
852 852
853 - 853 +
854 /* Put menu into the menubar */ 854 /* Put menu into the menubar */
855 menuItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""]; 855 menuItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""];
856 [menuItem setSubmenu:appleMenu]; 856 [menuItem setSubmenu:appleMenu];
@@ -872,17 +872,17 @@ static void setupWindowMenu(void) @@ -872,17 +872,17 @@ static void setupWindowMenu(void)
872 NSMenuItem *menuItem; 872 NSMenuItem *menuItem;
873 873
874 windowMenu = [[NSMenu alloc] initWithTitle:@"Window"]; 874 windowMenu = [[NSMenu alloc] initWithTitle:@"Window"];
875 - 875 +
876 /* "Minimize" item */ 876 /* "Minimize" item */
877 menuItem = [[NSMenuItem alloc] initWithTitle:@"Minimize" action:@selector(performMiniaturize:) keyEquivalent:@"m"]; 877 menuItem = [[NSMenuItem alloc] initWithTitle:@"Minimize" action:@selector(performMiniaturize:) keyEquivalent:@"m"];
878 [windowMenu addItem:menuItem]; 878 [windowMenu addItem:menuItem];
879 [menuItem release]; 879 [menuItem release];
880 - 880 +
881 /* Put menu into the menubar */ 881 /* Put menu into the menubar */
882 windowMenuItem = [[NSMenuItem alloc] initWithTitle:@"Window" action:nil keyEquivalent:@""]; 882 windowMenuItem = [[NSMenuItem alloc] initWithTitle:@"Window" action:nil keyEquivalent:@""];
883 [windowMenuItem setSubmenu:windowMenu]; 883 [windowMenuItem setSubmenu:windowMenu];
884 [[NSApp mainMenu] addItem:windowMenuItem]; 884 [[NSApp mainMenu] addItem:windowMenuItem];
885 - 885 +
886 /* Tell the application object that this is now the window menu */ 886 /* Tell the application object that this is now the window menu */
887 [NSApp setWindowsMenu:windowMenu]; 887 [NSApp setWindowsMenu:windowMenu];
888 888
@@ -896,14 +896,14 @@ static void CustomApplicationMain(void) @@ -896,14 +896,14 @@ static void CustomApplicationMain(void)
896 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 896 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
897 QemuCocoaGUIController *gui_controller; 897 QemuCocoaGUIController *gui_controller;
898 CPSProcessSerNum PSN; 898 CPSProcessSerNum PSN;
899 - 899 +
900 [NSApplication sharedApplication]; 900 [NSApplication sharedApplication];
901 - 901 +
902 if (!CPSGetCurrentProcess(&PSN)) 902 if (!CPSGetCurrentProcess(&PSN))
903 if (!CPSEnableForegroundOperation(&PSN,0x03,0x3C,0x2C,0x1103)) 903 if (!CPSEnableForegroundOperation(&PSN,0x03,0x3C,0x2C,0x1103))
904 if (!CPSSetFrontProcess(&PSN)) 904 if (!CPSSetFrontProcess(&PSN))
905 [NSApplication sharedApplication]; 905 [NSApplication sharedApplication];
906 - 906 +
907 /* Set up the menubar */ 907 /* Set up the menubar */
908 [NSApp setMainMenu:[[NSMenu alloc] init]]; 908 [NSApp setMainMenu:[[NSMenu alloc] init]];
909 setApplicationMenu(); 909 setApplicationMenu();
@@ -912,10 +912,10 @@ static void CustomApplicationMain(void) @@ -912,10 +912,10 @@ static void CustomApplicationMain(void)
912 /* Create SDLMain and make it the app delegate */ 912 /* Create SDLMain and make it the app delegate */
913 gui_controller = [[QemuCocoaGUIController alloc] init]; 913 gui_controller = [[QemuCocoaGUIController alloc] init];
914 [NSApp setDelegate:gui_controller]; 914 [NSApp setDelegate:gui_controller];
915 - 915 +
916 /* Start the main event loop */ 916 /* Start the main event loop */
917 [NSApp run]; 917 [NSApp run];
918 - 918 +
919 [gui_controller release]; 919 [gui_controller release];
920 [pool release]; 920 [pool release];
921 } 921 }
configure
@@ -403,7 +403,7 @@ if test &quot;$mingw32&quot; = &quot;yes&quot; ; then @@ -403,7 +403,7 @@ if test &quot;$mingw32&quot; = &quot;yes&quot; ; then
403 oss="no" 403 oss="no"
404 fi 404 fi
405 405
406 -# Check for gcc4, error if pre-gcc4 406 +# Check for gcc4, error if pre-gcc4
407 if test "$check_gcc" = "yes" ; then 407 if test "$check_gcc" = "yes" ; then
408 cat > $TMPC <<EOF 408 cat > $TMPC <<EOF
409 #if __GNUC__ < 4 409 #if __GNUC__ < 4
@@ -444,7 +444,7 @@ if test &quot;$solaris&quot; = &quot;yes&quot; ; then @@ -444,7 +444,7 @@ if test &quot;$solaris&quot; = &quot;yes&quot; ; then
444 # 444 #
445 # gcc for solaris 10/fcs in /usr/sfw/bin doesn't compile qemu correctly 445 # gcc for solaris 10/fcs in /usr/sfw/bin doesn't compile qemu correctly
446 # override the check with --disable-gcc-check 446 # override the check with --disable-gcc-check
447 - # 447 + #
448 if test "$solarisrev" -eq 10 -a "$check_gcc" = "yes" ; then 448 if test "$solarisrev" -eq 10 -a "$check_gcc" = "yes" ; then
449 solgcc=`which $cc` 449 solgcc=`which $cc`
450 if test "$solgcc" = "/usr/sfw/bin/gcc" ; then 450 if test "$solgcc" = "/usr/sfw/bin/gcc" ; then
@@ -475,7 +475,7 @@ if test &quot;$solaris&quot; = &quot;yes&quot; ; then @@ -475,7 +475,7 @@ if test &quot;$solaris&quot; = &quot;yes&quot; ; then
475 fi 475 fi
476 exit 1 476 exit 1
477 fi 477 fi
478 -fi 478 +fi
479 479
480 480
481 if test -z "$target_list" ; then 481 if test -z "$target_list" ; then
console.c
1 /* 1 /*
2 * QEMU graphical console 2 * QEMU graphical console
3 - * 3 + *
4 * Copyright (c) 2004 Fabrice Bellard 4 * Copyright (c) 2004 Fabrice Bellard
5 - * 5 + *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy 6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal 7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights 8 * in the Software without restriction, including without limitation the rights
@@ -180,8 +180,8 @@ static unsigned int vga_get_color(DisplayState *ds, unsigned int rgba) @@ -180,8 +180,8 @@ static unsigned int vga_get_color(DisplayState *ds, unsigned int rgba)
180 r = (rgba >> 16) & 0xff; 180 r = (rgba >> 16) & 0xff;
181 g = (rgba >> 8) & 0xff; 181 g = (rgba >> 8) & 0xff;
182 b = (rgba) & 0xff; 182 b = (rgba) & 0xff;
183 - color = (rgb_to_index[r] * 6 * 6) +  
184 - (rgb_to_index[g] * 6) + 183 + color = (rgb_to_index[r] * 6 * 6) +
  184 + (rgb_to_index[g] * 6) +
185 (rgb_to_index[b]); 185 (rgb_to_index[b]);
186 break; 186 break;
187 #endif 187 #endif
@@ -205,14 +205,14 @@ static unsigned int vga_get_color(DisplayState *ds, unsigned int rgba) @@ -205,14 +205,14 @@ static unsigned int vga_get_color(DisplayState *ds, unsigned int rgba)
205 return color; 205 return color;
206 } 206 }
207 207
208 -static void vga_fill_rect (DisplayState *ds, 208 +static void vga_fill_rect (DisplayState *ds,
209 int posx, int posy, int width, int height, uint32_t color) 209 int posx, int posy, int width, int height, uint32_t color)
210 { 210 {
211 uint8_t *d, *d1; 211 uint8_t *d, *d1;
212 int x, y, bpp; 212 int x, y, bpp;
213 - 213 +
214 bpp = (ds->depth + 7) >> 3; 214 bpp = (ds->depth + 7) >> 3;
215 - d1 = ds->data + 215 + d1 = ds->data +
216 ds->linesize * posy + bpp * posx; 216 ds->linesize * posy + bpp * posx;
217 for (y = 0; y < height; y++) { 217 for (y = 0; y < height; y++) {
218 d = d1; 218 d = d1;
@@ -250,9 +250,9 @@ static void vga_bitblt(DisplayState *ds, int xs, int ys, int xd, int yd, int w, @@ -250,9 +250,9 @@ static void vga_bitblt(DisplayState *ds, int xs, int ys, int xd, int yd, int w,
250 bpp = (ds->depth + 7) >> 3; 250 bpp = (ds->depth + 7) >> 3;
251 wb = w * bpp; 251 wb = w * bpp;
252 if (yd <= ys) { 252 if (yd <= ys) {
253 - s = ds->data + 253 + s = ds->data +
254 ds->linesize * ys + bpp * xs; 254 ds->linesize * ys + bpp * xs;
255 - d = ds->data + 255 + d = ds->data +
256 ds->linesize * yd + bpp * xd; 256 ds->linesize * yd + bpp * xd;
257 for (y = 0; y < h; y++) { 257 for (y = 0; y < h; y++) {
258 memmove(d, s, wb); 258 memmove(d, s, wb);
@@ -260,9 +260,9 @@ static void vga_bitblt(DisplayState *ds, int xs, int ys, int xd, int yd, int w, @@ -260,9 +260,9 @@ static void vga_bitblt(DisplayState *ds, int xs, int ys, int xd, int yd, int w,
260 s += ds->linesize; 260 s += ds->linesize;
261 } 261 }
262 } else { 262 } else {
263 - s = ds->data + 263 + s = ds->data +
264 ds->linesize * (ys + h - 1) + bpp * xs; 264 ds->linesize * (ys + h - 1) + bpp * xs;
265 - d = ds->data + 265 + d = ds->data +
266 ds->linesize * (yd + h - 1) + bpp * xd; 266 ds->linesize * (yd + h - 1) + bpp * xd;
267 for (y = 0; y < h; y++) { 267 for (y = 0; y < h; y++) {
268 memmove(d, s, wb); 268 memmove(d, s, wb);
@@ -405,7 +405,7 @@ static void console_print_text_attributes(TextAttributes *t_attrib, char ch) @@ -405,7 +405,7 @@ static void console_print_text_attributes(TextAttributes *t_attrib, char ch)
405 } 405 }
406 #endif 406 #endif
407 407
408 -static void vga_putcharxy(DisplayState *ds, int x, int y, int ch, 408 +static void vga_putcharxy(DisplayState *ds, int x, int y, int ch,
409 TextAttributes *t_attrib) 409 TextAttributes *t_attrib)
410 { 410 {
411 uint8_t *d; 411 uint8_t *d;
@@ -428,7 +428,7 @@ static void vga_putcharxy(DisplayState *ds, int x, int y, int ch, @@ -428,7 +428,7 @@ static void vga_putcharxy(DisplayState *ds, int x, int y, int ch,
428 } 428 }
429 429
430 bpp = (ds->depth + 7) >> 3; 430 bpp = (ds->depth + 7) >> 3;
431 - d = ds->data + 431 + d = ds->data +
432 ds->linesize * y * FONT_HEIGHT + bpp * x * FONT_WIDTH; 432 ds->linesize * y * FONT_HEIGHT + bpp * x * FONT_WIDTH;
433 linesize = ds->linesize; 433 linesize = ds->linesize;
434 font_ptr = vgafont16 + FONT_HEIGHT * ch; 434 font_ptr = vgafont16 + FONT_HEIGHT * ch;
@@ -525,9 +525,9 @@ static void update_xy(TextConsole *s, int x, int y) @@ -525,9 +525,9 @@ static void update_xy(TextConsole *s, int x, int y)
525 y2 += s->total_height; 525 y2 += s->total_height;
526 if (y2 < s->height) { 526 if (y2 < s->height) {
527 c = &s->cells[y1 * s->width + x]; 527 c = &s->cells[y1 * s->width + x];
528 - vga_putcharxy(s->ds, x, y2, c->ch, 528 + vga_putcharxy(s->ds, x, y2, c->ch,
529 &(c->t_attrib)); 529 &(c->t_attrib));
530 - dpy_update(s->ds, x * FONT_WIDTH, y2 * FONT_HEIGHT, 530 + dpy_update(s->ds, x * FONT_WIDTH, y2 * FONT_HEIGHT,
531 FONT_WIDTH, FONT_HEIGHT); 531 FONT_WIDTH, FONT_HEIGHT);
532 } 532 }
533 } 533 }
@@ -556,7 +556,7 @@ static void console_show_cursor(TextConsole *s, int show) @@ -556,7 +556,7 @@ static void console_show_cursor(TextConsole *s, int show)
556 } else { 556 } else {
557 vga_putcharxy(s->ds, x, y, c->ch, &(c->t_attrib)); 557 vga_putcharxy(s->ds, x, y, c->ch, &(c->t_attrib));
558 } 558 }
559 - dpy_update(s->ds, x * FONT_WIDTH, y * FONT_HEIGHT, 559 + dpy_update(s->ds, x * FONT_WIDTH, y * FONT_HEIGHT,
560 FONT_WIDTH, FONT_HEIGHT); 560 FONT_WIDTH, FONT_HEIGHT);
561 } 561 }
562 } 562 }
@@ -567,7 +567,7 @@ static void console_refresh(TextConsole *s) @@ -567,7 +567,7 @@ static void console_refresh(TextConsole *s)
567 TextCell *c; 567 TextCell *c;
568 int x, y, y1; 568 int x, y, y1;
569 569
570 - if (s != active_console) 570 + if (s != active_console)
571 return; 571 return;
572 572
573 vga_fill_rect(s->ds, 0, 0, s->ds->width, s->ds->height, 573 vga_fill_rect(s->ds, 0, 0, s->ds->width, s->ds->height,
@@ -576,7 +576,7 @@ static void console_refresh(TextConsole *s) @@ -576,7 +576,7 @@ static void console_refresh(TextConsole *s)
576 for(y = 0; y < s->height; y++) { 576 for(y = 0; y < s->height; y++) {
577 c = s->cells + y1 * s->width; 577 c = s->cells + y1 * s->width;
578 for(x = 0; x < s->width; x++) { 578 for(x = 0; x < s->width; x++) {
579 - vga_putcharxy(s->ds, x, y, c->ch, 579 + vga_putcharxy(s->ds, x, y, c->ch,
580 &(c->t_attrib)); 580 &(c->t_attrib));
581 c++; 581 c++;
582 } 582 }
@@ -591,7 +591,7 @@ static void console_scroll(int ydelta) @@ -591,7 +591,7 @@ static void console_scroll(int ydelta)
591 { 591 {
592 TextConsole *s; 592 TextConsole *s;
593 int i, y1; 593 int i, y1;
594 - 594 +
595 s = active_console; 595 s = active_console;
596 if (!s || (s->console_type == GRAPHIC_CONSOLE)) 596 if (!s || (s->console_type == GRAPHIC_CONSOLE))
597 return; 597 return;
@@ -646,13 +646,13 @@ static void console_put_lf(TextConsole *s) @@ -646,13 +646,13 @@ static void console_put_lf(TextConsole *s)
646 c++; 646 c++;
647 } 647 }
648 if (s == active_console && s->y_displayed == s->y_base) { 648 if (s == active_console && s->y_displayed == s->y_base) {
649 - vga_bitblt(s->ds, 0, FONT_HEIGHT, 0, 0,  
650 - s->width * FONT_WIDTH, 649 + vga_bitblt(s->ds, 0, FONT_HEIGHT, 0, 0,
  650 + s->width * FONT_WIDTH,
651 (s->height - 1) * FONT_HEIGHT); 651 (s->height - 1) * FONT_HEIGHT);
652 vga_fill_rect(s->ds, 0, (s->height - 1) * FONT_HEIGHT, 652 vga_fill_rect(s->ds, 0, (s->height - 1) * FONT_HEIGHT,
653 - s->width * FONT_WIDTH, FONT_HEIGHT, 653 + s->width * FONT_WIDTH, FONT_HEIGHT,
654 color_table[0][s->t_attrib_default.bgcol]); 654 color_table[0][s->t_attrib_default.bgcol]);
655 - dpy_update(s->ds, 0, 0, 655 + dpy_update(s->ds, 0, 0,
656 s->width * FONT_WIDTH, s->height * FONT_HEIGHT); 656 s->width * FONT_WIDTH, s->height * FONT_HEIGHT);
657 } 657 }
658 } 658 }
@@ -781,7 +781,7 @@ static void console_putchar(TextConsole *s, int ch) @@ -781,7 +781,7 @@ static void console_putchar(TextConsole *s, int ch)
781 console_put_lf(s); 781 console_put_lf(s);
782 break; 782 break;
783 case '\b': /* backspace */ 783 case '\b': /* backspace */
784 - if (s->x > 0) 784 + if (s->x > 0)
785 s->x--; 785 s->x--;
786 break; 786 break;
787 case '\t': /* tabspace */ 787 case '\t': /* tabspace */
@@ -832,7 +832,7 @@ static void console_putchar(TextConsole *s, int ch) @@ -832,7 +832,7 @@ static void console_putchar(TextConsole *s, int ch)
832 case TTY_STATE_CSI: /* handle escape sequence parameters */ 832 case TTY_STATE_CSI: /* handle escape sequence parameters */
833 if (ch >= '0' && ch <= '9') { 833 if (ch >= '0' && ch <= '9') {
834 if (s->nb_esc_params < MAX_ESC_PARAMS) { 834 if (s->nb_esc_params < MAX_ESC_PARAMS) {
835 - s->esc_params[s->nb_esc_params] = 835 + s->esc_params[s->nb_esc_params] =
836 s->esc_params[s->nb_esc_params] * 10 + ch - '0'; 836 s->esc_params[s->nb_esc_params] * 10 + ch - '0';
837 } 837 }
838 } else { 838 } else {
@@ -1047,7 +1047,7 @@ static void kbd_send_chars(void *opaque) @@ -1047,7 +1047,7 @@ static void kbd_send_chars(void *opaque)
1047 TextConsole *s = opaque; 1047 TextConsole *s = opaque;
1048 int len; 1048 int len;
1049 uint8_t buf[16]; 1049 uint8_t buf[16];
1050 - 1050 +
1051 len = qemu_chr_can_read(s->chr); 1051 len = qemu_chr_can_read(s->chr);
1052 if (len > s->out_fifo.count) 1052 if (len > s->out_fifo.count)
1053 len = s->out_fifo.count; 1053 len = s->out_fifo.count;
@@ -1192,12 +1192,12 @@ CharDriverState *text_console_init(DisplayState *ds, const char *p) @@ -1192,12 +1192,12 @@ CharDriverState *text_console_init(DisplayState *ds, const char *p)
1192 s->out_fifo.buf = s->out_fifo_buf; 1192 s->out_fifo.buf = s->out_fifo_buf;
1193 s->out_fifo.buf_size = sizeof(s->out_fifo_buf); 1193 s->out_fifo.buf_size = sizeof(s->out_fifo_buf);
1194 s->kbd_timer = qemu_new_timer(rt_clock, kbd_send_chars, s); 1194 s->kbd_timer = qemu_new_timer(rt_clock, kbd_send_chars, s);
1195 - 1195 +
1196 if (!color_inited) { 1196 if (!color_inited) {
1197 color_inited = 1; 1197 color_inited = 1;
1198 for(j = 0; j < 2; j++) { 1198 for(j = 0; j < 2; j++) {
1199 for(i = 0; i < 8; i++) { 1199 for(i = 0; i < 8; i++) {
1200 - color_table[j][i] = col_expand(s->ds, 1200 + color_table[j][i] = col_expand(s->ds,
1201 vga_get_color(s->ds, color_table_rgb[j][i])); 1201 vga_get_color(s->ds, color_table_rgb[j][i]));
1202 } 1202 }
1203 } 1203 }
cpu-all.h
1 /* 1 /*
2 * defines common to all virtual CPUs 2 * defines common to all virtual CPUs
3 - * 3 + *
4 * Copyright (c) 2003 Fabrice Bellard 4 * Copyright (c) 2003 Fabrice Bellard
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
@@ -24,16 +24,16 @@ @@ -24,16 +24,16 @@
24 #define WORDS_ALIGNED 24 #define WORDS_ALIGNED
25 #endif 25 #endif
26 26
27 -/* some important defines:  
28 - * 27 +/* some important defines:
  28 + *
29 * WORDS_ALIGNED : if defined, the host cpu can only make word aligned 29 * WORDS_ALIGNED : if defined, the host cpu can only make word aligned
30 * memory accesses. 30 * memory accesses.
31 - * 31 + *
32 * WORDS_BIGENDIAN : if defined, the host cpu is big endian and 32 * WORDS_BIGENDIAN : if defined, the host cpu is big endian and
33 * otherwise little endian. 33 * otherwise little endian.
34 - * 34 + *
35 * (TARGET_WORDS_ALIGNED : same for target cpu (not supported yet)) 35 * (TARGET_WORDS_ALIGNED : same for target cpu (not supported yet))
36 - * 36 + *
37 * TARGET_WORDS_BIGENDIAN : same for target cpu 37 * TARGET_WORDS_BIGENDIAN : same for target cpu
38 */ 38 */
39 39
@@ -147,7 +147,7 @@ typedef union { @@ -147,7 +147,7 @@ typedef union {
147 * type is: 147 * type is:
148 * (empty): integer access 148 * (empty): integer access
149 * f : float access 149 * f : float access
150 - * 150 + *
151 * sign is: 151 * sign is:
152 * (empty): for floats or 32 bit size 152 * (empty): for floats or 32 bit size
153 * u : unsigned 153 * u : unsigned
@@ -158,7 +158,7 @@ typedef union { @@ -158,7 +158,7 @@ typedef union {
158 * w: 16 bits 158 * w: 16 bits
159 * l: 32 bits 159 * l: 32 bits
160 * q: 64 bits 160 * q: 64 bits
161 - * 161 + *
162 * endian is: 162 * endian is:
163 * (empty): target cpu endianness or 8 bit access 163 * (empty): target cpu endianness or 8 bit access
164 * r : reversed target cpu endianness (not implemented yet) 164 * r : reversed target cpu endianness (not implemented yet)
@@ -621,7 +621,7 @@ static inline void stfq_be_p(void *ptr, float64 v) @@ -621,7 +621,7 @@ static inline void stfq_be_p(void *ptr, float64 v)
621 #define stfq_raw(p, v) stfq_p(saddr((p)), v) 621 #define stfq_raw(p, v) stfq_p(saddr((p)), v)
622 622
623 623
624 -#if defined(CONFIG_USER_ONLY) 624 +#if defined(CONFIG_USER_ONLY)
625 625
626 /* if user mode, no other memory access functions */ 626 /* if user mode, no other memory access functions */
627 #define ldub(p) ldub_raw(p) 627 #define ldub(p) ldub_raw(p)
@@ -685,7 +685,7 @@ extern unsigned long qemu_host_page_mask; @@ -685,7 +685,7 @@ extern unsigned long qemu_host_page_mask;
685 #define PAGE_VALID 0x0008 685 #define PAGE_VALID 0x0008
686 /* original state of the write flag (used when tracking self-modifying 686 /* original state of the write flag (used when tracking self-modifying
687 code */ 687 code */
688 -#define PAGE_WRITE_ORG 0x0010 688 +#define PAGE_WRITE_ORG 0x0010
689 689
690 void page_dump(FILE *f); 690 void page_dump(FILE *f);
691 int page_get_flags(target_ulong address); 691 int page_get_flags(target_ulong address);
@@ -694,7 +694,7 @@ void page_unprotect_range(target_ulong data, target_ulong data_size); @@ -694,7 +694,7 @@ void page_unprotect_range(target_ulong data, target_ulong data_size);
694 694
695 CPUState *cpu_copy(CPUState *env); 695 CPUState *cpu_copy(CPUState *env);
696 696
697 -void cpu_dump_state(CPUState *env, FILE *f, 697 +void cpu_dump_state(CPUState *env, FILE *f,
698 int (*cpu_fprintf)(FILE *f, const char *fmt, ...), 698 int (*cpu_fprintf)(FILE *f, const char *fmt, ...),
699 int flags); 699 int flags);
700 void cpu_dump_statistics (CPUState *env, FILE *f, 700 void cpu_dump_statistics (CPUState *env, FILE *f,
@@ -732,7 +732,7 @@ void cpu_reset(CPUState *s); @@ -732,7 +732,7 @@ void cpu_reset(CPUState *s);
732 if no page found. */ 732 if no page found. */
733 target_phys_addr_t cpu_get_phys_page_debug(CPUState *env, target_ulong addr); 733 target_phys_addr_t cpu_get_phys_page_debug(CPUState *env, target_ulong addr);
734 734
735 -#define CPU_LOG_TB_OUT_ASM (1 << 0) 735 +#define CPU_LOG_TB_OUT_ASM (1 << 0)
736 #define CPU_LOG_TB_IN_ASM (1 << 1) 736 #define CPU_LOG_TB_IN_ASM (1 << 1)
737 #define CPU_LOG_TB_OP (1 << 2) 737 #define CPU_LOG_TB_OP (1 << 2)
738 #define CPU_LOG_TB_OP_OPT (1 << 3) 738 #define CPU_LOG_TB_OP_OPT (1 << 3)
@@ -793,7 +793,7 @@ extern uint8_t *phys_ram_dirty; @@ -793,7 +793,7 @@ extern uint8_t *phys_ram_dirty;
793 typedef void CPUWriteMemoryFunc(void *opaque, target_phys_addr_t addr, uint32_t value); 793 typedef void CPUWriteMemoryFunc(void *opaque, target_phys_addr_t addr, uint32_t value);
794 typedef uint32_t CPUReadMemoryFunc(void *opaque, target_phys_addr_t addr); 794 typedef uint32_t CPUReadMemoryFunc(void *opaque, target_phys_addr_t addr);
795 795
796 -void cpu_register_physical_memory(target_phys_addr_t start_addr, 796 +void cpu_register_physical_memory(target_phys_addr_t start_addr,
797 unsigned long size, 797 unsigned long size,
798 unsigned long phys_offset); 798 unsigned long phys_offset);
799 uint32_t cpu_get_physical_page_desc(target_phys_addr_t addr); 799 uint32_t cpu_get_physical_page_desc(target_phys_addr_t addr);
@@ -808,12 +808,12 @@ CPUReadMemoryFunc **cpu_get_io_memory_read(int io_index); @@ -808,12 +808,12 @@ CPUReadMemoryFunc **cpu_get_io_memory_read(int io_index);
808 808
809 void cpu_physical_memory_rw(target_phys_addr_t addr, uint8_t *buf, 809 void cpu_physical_memory_rw(target_phys_addr_t addr, uint8_t *buf,
810 int len, int is_write); 810 int len, int is_write);
811 -static inline void cpu_physical_memory_read(target_phys_addr_t addr, 811 +static inline void cpu_physical_memory_read(target_phys_addr_t addr,
812 uint8_t *buf, int len) 812 uint8_t *buf, int len)
813 { 813 {
814 cpu_physical_memory_rw(addr, buf, len, 0); 814 cpu_physical_memory_rw(addr, buf, len, 0);
815 } 815 }
816 -static inline void cpu_physical_memory_write(target_phys_addr_t addr, 816 +static inline void cpu_physical_memory_write(target_phys_addr_t addr,
817 const uint8_t *buf, int len) 817 const uint8_t *buf, int len)
818 { 818 {
819 cpu_physical_memory_rw(addr, (uint8_t *)buf, len, 1); 819 cpu_physical_memory_rw(addr, (uint8_t *)buf, len, 1);
@@ -829,9 +829,9 @@ void stw_phys(target_phys_addr_t addr, uint32_t val); @@ -829,9 +829,9 @@ void stw_phys(target_phys_addr_t addr, uint32_t val);
829 void stl_phys(target_phys_addr_t addr, uint32_t val); 829 void stl_phys(target_phys_addr_t addr, uint32_t val);
830 void stq_phys(target_phys_addr_t addr, uint64_t val); 830 void stq_phys(target_phys_addr_t addr, uint64_t val);
831 831
832 -void cpu_physical_memory_write_rom(target_phys_addr_t addr, 832 +void cpu_physical_memory_write_rom(target_phys_addr_t addr,
833 const uint8_t *buf, int len); 833 const uint8_t *buf, int len);
834 -int cpu_memory_rw_debug(CPUState *env, target_ulong addr, 834 +int cpu_memory_rw_debug(CPUState *env, target_ulong addr,
835 uint8_t *buf, int len, int is_write); 835 uint8_t *buf, int len, int is_write);
836 836
837 #define VGA_DIRTY_FLAG 0x01 837 #define VGA_DIRTY_FLAG 0x01
@@ -843,7 +843,7 @@ static inline int cpu_physical_memory_is_dirty(ram_addr_t addr) @@ -843,7 +843,7 @@ static inline int cpu_physical_memory_is_dirty(ram_addr_t addr)
843 return phys_ram_dirty[addr >> TARGET_PAGE_BITS] == 0xff; 843 return phys_ram_dirty[addr >> TARGET_PAGE_BITS] == 0xff;
844 } 844 }
845 845
846 -static inline int cpu_physical_memory_get_dirty(ram_addr_t addr, 846 +static inline int cpu_physical_memory_get_dirty(ram_addr_t addr,
847 int dirty_flags) 847 int dirty_flags)
848 { 848 {
849 return phys_ram_dirty[addr >> TARGET_PAGE_BITS] & dirty_flags; 849 return phys_ram_dirty[addr >> TARGET_PAGE_BITS] & dirty_flags;
@@ -866,14 +866,14 @@ void dump_exec_info(FILE *f, @@ -866,14 +866,14 @@ void dump_exec_info(FILE *f,
866 866
867 #if defined(__powerpc__) 867 #if defined(__powerpc__)
868 868
869 -static inline uint32_t get_tbl(void) 869 +static inline uint32_t get_tbl(void)
870 { 870 {
871 uint32_t tbl; 871 uint32_t tbl;
872 asm volatile("mftb %0" : "=r" (tbl)); 872 asm volatile("mftb %0" : "=r" (tbl));
873 return tbl; 873 return tbl;
874 } 874 }
875 875
876 -static inline uint32_t get_tbu(void) 876 +static inline uint32_t get_tbu(void)
877 { 877 {
878 uint32_t tbl; 878 uint32_t tbl;
879 asm volatile("mftbu %0" : "=r" (tbl)); 879 asm volatile("mftbu %0" : "=r" (tbl));
cpu-defs.h
1 /* 1 /*
2 * common defines for all CPUs 2 * common defines for all CPUs
3 - * 3 + *
4 * Copyright (c) 2003 Fabrice Bellard 4 * Copyright (c) 2003 Fabrice Bellard
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
@@ -29,7 +29,7 @@ @@ -29,7 +29,7 @@
29 #error TARGET_LONG_BITS must be defined before including this header 29 #error TARGET_LONG_BITS must be defined before including this header
30 #endif 30 #endif
31 31
32 -#ifndef TARGET_PHYS_ADDR_BITS 32 +#ifndef TARGET_PHYS_ADDR_BITS
33 #if TARGET_LONG_BITS >= HOST_LONG_BITS 33 #if TARGET_LONG_BITS >= HOST_LONG_BITS
34 #define TARGET_PHYS_ADDR_BITS TARGET_LONG_BITS 34 #define TARGET_PHYS_ADDR_BITS TARGET_LONG_BITS
35 #else 35 #else
@@ -97,17 +97,17 @@ typedef unsigned long ram_addr_t; @@ -97,17 +97,17 @@ typedef unsigned long ram_addr_t;
97 #define CPU_TLB_SIZE (1 << CPU_TLB_BITS) 97 #define CPU_TLB_SIZE (1 << CPU_TLB_BITS)
98 98
99 typedef struct CPUTLBEntry { 99 typedef struct CPUTLBEntry {
100 - /* bit 31 to TARGET_PAGE_BITS : virtual address 100 + /* bit 31 to TARGET_PAGE_BITS : virtual address
101 bit TARGET_PAGE_BITS-1..IO_MEM_SHIFT : if non zero, memory io 101 bit TARGET_PAGE_BITS-1..IO_MEM_SHIFT : if non zero, memory io
102 zone number 102 zone number
103 bit 3 : indicates that the entry is invalid 103 bit 3 : indicates that the entry is invalid
104 bit 2..0 : zero 104 bit 2..0 : zero
105 */ 105 */
106 - target_ulong addr_read;  
107 - target_ulong addr_write;  
108 - target_ulong addr_code; 106 + target_ulong addr_read;
  107 + target_ulong addr_write;
  108 + target_ulong addr_code;
109 /* addend to virtual address to get physical address */ 109 /* addend to virtual address to get physical address */
110 - target_phys_addr_t addend; 110 + target_phys_addr_t addend;
111 } CPUTLBEntry; 111 } CPUTLBEntry;
112 112
113 /* Alpha has 4 different running levels */ 113 /* Alpha has 4 different running levels */