| lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 |  | 
|  | 2 | #include "zconf.h" | 
|  | 3 |  | 
|  | 4 | extern char input_data[]; | 
|  | 5 | extern char input_data_end[]; | 
|  | 6 |  | 
|  | 7 | unsigned char *output_data     = NULL; | 
|  | 8 |  | 
|  | 9 | unsigned long free_mem_ptr     = 0; | 
|  | 10 | unsigned long free_mem_end_ptr = 0; | 
|  | 11 |  | 
|  | 12 | void error(char *x) | 
|  | 13 | { | 
|  | 14 | while(1); | 
|  | 15 | } | 
|  | 16 |  | 
|  | 17 | extern int do_decompress(u8 *input, int len, u8 *output, void (*error)(char *x)); | 
|  | 18 |  | 
|  | 19 | void decompress_kernel(unsigned long output_start, unsigned long free_mem_ptr_p, unsigned long free_mem_ptr_end_p) | 
|  | 20 | { | 
|  | 21 | output_data      = (unsigned char *)output_start; | 
|  | 22 | free_mem_ptr     = free_mem_ptr_p; | 
|  | 23 | free_mem_end_ptr = free_mem_ptr_end_p; | 
|  | 24 |  | 
|  | 25 | do_decompress((u8 *)input_data, input_data_end - input_data + 1, output_data, error); | 
|  | 26 | } | 
|  | 27 |  | 
|  | 28 | typedef unsigned long CYG_WORD; | 
|  | 29 |  | 
|  | 30 | #define CYG_STR_UNALIGNED(X, Y) \ | 
|  | 31 | (((CYG_WORD)(X) & (sizeof (CYG_WORD) - 1)) | \ | 
|  | 32 | ((CYG_WORD)(Y) & (sizeof (CYG_WORD) - 1))) | 
|  | 33 |  | 
|  | 34 | #define CYG_STR_OPT_BIGBLOCKSIZE     (sizeof(CYG_WORD) << 2) | 
|  | 35 |  | 
|  | 36 | #define CYG_STR_OPT_LITTLEBLOCKSIZE (sizeof (CYG_WORD)) | 
|  | 37 |  | 
|  | 38 | void *memcpy( void *s1, const void *s2, size_t n ) | 
|  | 39 | { | 
|  | 40 | char *dst = (char *) s1; | 
|  | 41 | const char *src = (const char *) s2; | 
|  | 42 | CYG_WORD *aligned_dst; | 
|  | 43 | const CYG_WORD *aligned_src; | 
|  | 44 |  | 
|  | 45 | if (dst == src) | 
|  | 46 | return s1; | 
|  | 47 |  | 
|  | 48 | if (n < sizeof(CYG_WORD) || CYG_STR_UNALIGNED (src, dst)) | 
|  | 49 | { | 
|  | 50 | while (n--) | 
|  | 51 | *dst++ = *src++; | 
|  | 52 | return s1; | 
|  | 53 | } | 
|  | 54 |  | 
|  | 55 | aligned_dst = (CYG_WORD *)dst; | 
|  | 56 | aligned_src = (const CYG_WORD *)src; | 
|  | 57 |  | 
|  | 58 | while (n >= CYG_STR_OPT_BIGBLOCKSIZE) | 
|  | 59 | { | 
|  | 60 | *aligned_dst++ = *aligned_src++; | 
|  | 61 | *aligned_dst++ = *aligned_src++; | 
|  | 62 | *aligned_dst++ = *aligned_src++; | 
|  | 63 | *aligned_dst++ = *aligned_src++; | 
|  | 64 | n -= CYG_STR_OPT_BIGBLOCKSIZE; | 
|  | 65 | } | 
|  | 66 |  | 
|  | 67 | while (n >= CYG_STR_OPT_LITTLEBLOCKSIZE) | 
|  | 68 | { | 
|  | 69 | *aligned_dst++ = *aligned_src++; | 
|  | 70 | n -= CYG_STR_OPT_LITTLEBLOCKSIZE; | 
|  | 71 | } | 
|  | 72 |  | 
|  | 73 | dst = (char*)aligned_dst; | 
|  | 74 | src = (const char*)aligned_src; | 
|  | 75 | while (n--) | 
|  | 76 | *dst++ = *src++; | 
|  | 77 |  | 
|  | 78 | return s1; | 
|  | 79 | } |