grub-extras/lua: add fs label to grub.enum_device
[grub-extras.git] / disabled / gpxe / wrap / wrap.c
blob691e5521580cfb320e55a4751baab6d0fffbaced
1 /*
2 * Copyright © 2009 Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>
3 * All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
9 * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
12 * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
15 * distribution.
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
20 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
22 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
28 * OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
31 FILE_LICENCE ( BSD2 );
33 #include <gpxe/wrap.h>
34 #include <gpxe/uaccess.h>
36 void
37 memcpy_user (userptr_t dest, off_t dest_off,
38 userptr_t src, off_t src_off, size_t len )
40 grub_memcpy ((void *) dest+dest_off, (void *) src+src_off, len);
43 userptr_t
44 virt_to_user (volatile const void *in)
46 return in;
49 void
50 free_memblock (void *ptr, size_t size __attribute__ ((unused)))
52 grub_free (ptr);
55 void *
56 memchr (void *s, grub_uint8_t c, grub_size_t size)
58 for (;size && *(grub_uint8_t *)s != c; size--, s = (grub_uint8_t *)s + 1);
59 if (size)
60 return s;
61 return NULL;
64 grub_size_t
65 strnlen (char *str, grub_size_t n)
67 grub_size_t r = 0;
68 while (*str && n)
70 str++;
71 n--;
72 r++;
74 return r;