Revision 5fafdf24

b/Changelog
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 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 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 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 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 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 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 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
b/Makefile
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 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:
b/Makefile.target
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 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 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 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 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 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
b/TODO
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
b/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 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 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 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
}
b/alpha-dis.c
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 */
b/arm-dis.c
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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 976
			  func (stream, "3");
977 977
			}
978 978
		      break;
979
			
979
		
980 980
		    case 'P':
981 981
		      switch (given & 0x00080080)
982 982
			{
......
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 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 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 1163
				    }
1164 1164
				  break;
1165 1165

  
1166
				  
1166
				 
1167 1167
				default:
1168 1168
				  abort ();
1169 1169
				}
......
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 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 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 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 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 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 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 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 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 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 1512
     char * options;
1513 1513
{
1514 1514
  char * space;
1515
  
1515
 
1516 1516
  if (options == NULL)
1517 1517
    return;
1518 1518

  
......
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 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 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 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 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 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 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,
b/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 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 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 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);
b/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 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 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 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 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 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 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 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 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 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;
b/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 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 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 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;
b/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 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 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 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 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 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;
b/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 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 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 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 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 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;
b/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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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;
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff