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