~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/xtensa/boot/lib/zmem.c

Version: ~ [ linux-5.5-rc7 ] ~ [ linux-5.4.13 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.97 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.166 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.210 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.210 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.81 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 #include <linux/zlib.h>
  2 
  3 /* bits taken from ppc */
  4 
  5 extern void *avail_ram, *end_avail;
  6 
  7 void exit (void)
  8 {
  9   for (;;);
 10 }
 11 
 12 void *zalloc(unsigned size)
 13 {
 14         void *p = avail_ram;
 15 
 16         size = (size + 7) & -8;
 17         avail_ram += size;
 18         if (avail_ram > end_avail) {
 19                 //puts("oops... out of memory\n");
 20                 //pause();
 21                 exit ();
 22         }
 23         return p;
 24 }
 25 
 26 #define HEAD_CRC        2
 27 #define EXTRA_FIELD     4
 28 #define ORIG_NAME       8
 29 #define COMMENT         0x10
 30 #define RESERVED        0xe0
 31 
 32 #define DEFLATED        8
 33 
 34 void gunzip (void *dst, int dstlen, unsigned char *src, int *lenp)
 35 {
 36         z_stream s;
 37         int r, i, flags;
 38 
 39         /* skip header */
 40         i = 10;
 41         flags = src[3];
 42         if (src[2] != DEFLATED || (flags & RESERVED) != 0) {
 43                 //puts("bad gzipped data\n");
 44                 exit();
 45         }
 46         if ((flags & EXTRA_FIELD) != 0)
 47                 i = 12 + src[10] + (src[11] << 8);
 48         if ((flags & ORIG_NAME) != 0)
 49                 while (src[i++] != 0)
 50                         ;
 51         if ((flags & COMMENT) != 0)
 52                 while (src[i++] != 0)
 53                         ;
 54         if ((flags & HEAD_CRC) != 0)
 55                 i += 2;
 56         if (i >= *lenp) {
 57                 //puts("gunzip: ran out of data in header\n");
 58                 exit();
 59         }
 60 
 61         s.workspace = zalloc(zlib_inflate_workspacesize());
 62         r = zlib_inflateInit2(&s, -MAX_WBITS);
 63         if (r != Z_OK) {
 64                 //puts("inflateInit2 returned "); puthex(r); puts("\n");
 65                 exit();
 66         }
 67         s.next_in = src + i;
 68         s.avail_in = *lenp - i;
 69         s.next_out = dst;
 70         s.avail_out = dstlen;
 71         r = zlib_inflate(&s, Z_FINISH);
 72         if (r != Z_OK && r != Z_STREAM_END) {
 73                 //puts("inflate returned "); puthex(r); puts("\n");
 74                 exit();
 75         }
 76         *lenp = s.next_out - (unsigned char *) dst;
 77         zlib_inflateEnd(&s);
 78 }
 79 
 80 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp