source: grub-pc/trunk/fuentes/grub-core/boot/decompressor/minilib.c @ 22

Last change on this file since 22 was 22, checked in by mabarracus, 4 years ago

updated version and apply net.ifnames=0 into debian/rules

File size: 2.3 KB
Line 
1/*
2 *  GRUB  --  GRand Unified Bootloader
3 *  Copyright (C) 2010  Free Software Foundation, Inc.
4 *
5 *  GRUB is free software: you can redistribute it and/or modify
6 *  it under the terms of the GNU General Public License as published by
7 *  the Free Software Foundation, either version 3 of the License, or
8 *  (at your option) any later version.
9 *
10 *  GRUB is distributed in the hope that it will be useful,
11 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 *  GNU General Public License for more details.
14 *
15 *  You should have received a copy of the GNU General Public License
16 *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#include <grub/types.h>
20#include <grub/misc.h>
21#include <grub/decompressor.h>
22
23void *
24memset (void *s, int c, grub_size_t len)
25{
26  grub_uint8_t *ptr;
27  for (ptr = s; len; ptr++, len--)
28    *ptr = c;
29  return s;
30}
31
32void *
33grub_memmove (void *dest, const void *src, grub_size_t n)
34{
35  char *d = (char *) dest;
36  const char *s = (const char *) src;
37
38  if (d < s)
39    while (n--)
40      *d++ = *s++;
41  else
42    {
43      d += n;
44      s += n;
45
46      while (n--)
47        *--d = *--s;
48    }
49
50  return dest;
51}
52
53int
54grub_memcmp (const void *s1, const void *s2, grub_size_t n)
55{
56  const unsigned char *t1 = s1;
57  const unsigned char *t2 = s2;
58
59  while (n--)
60    {
61      if (*t1 != *t2)
62        return (int) *t1 - (int) *t2;
63
64      t1++;
65      t2++;
66    }
67
68  return 0;
69}
70
71int memcmp (const void *s1, const void *s2, grub_size_t n)
72  __attribute__ ((alias ("grub_memcmp")));
73
74void *memmove (void *dest, const void *src, grub_size_t n)
75  __attribute__ ((alias ("grub_memmove")));
76
77void *memcpy (void *dest, const void *src, grub_size_t n)
78  __attribute__ ((alias ("grub_memmove")));
79
80void *grub_decompressor_scratch;
81
82void
83find_scratch (void *src, void *dst, unsigned long srcsize,
84              unsigned long dstsize)
85{
86#ifdef _mips
87  /* Decoding from ROM.  */
88  if (((grub_addr_t) src & 0x10000000))
89    {
90      grub_decompressor_scratch = (void *) ALIGN_UP((grub_addr_t) dst + dstsize,
91                                                    256);
92      return;
93    }
94#endif
95  if ((char *) src + srcsize > (char *) dst + dstsize)
96    grub_decompressor_scratch = (void *) ALIGN_UP ((grub_addr_t) src + srcsize,
97                                                   256);
98  else
99    grub_decompressor_scratch = (void *) ALIGN_UP ((grub_addr_t) dst + dstsize,
100                                                   256);
101  return;
102}
Note: See TracBrowser for help on using the repository browser.