Add support for a root disk device file.
[dragonfly.git] / sys / platform / vkernel / platform / copyio.c
1 /*
2  * Copyright (c) 2006 The DragonFly Project.  All rights reserved.
3  * 
4  * This code is derived from software contributed to The DragonFly Project
5  * by Matthew Dillon <dillon@backplane.com>
6  * 
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in
15  *    the documentation and/or other materials provided with the
16  *    distribution.
17  * 3. Neither the name of The DragonFly Project nor the names of its
18  *    contributors may be used to endorse or promote products derived
19  *    from this software without specific, prior written permission.
20  * 
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
25  * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
31  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32  * SUCH DAMAGE.
33  * 
34  * $DragonFly: src/sys/platform/vkernel/platform/copyio.c,v 1.4 2007/01/07 02:42:24 dillon Exp $
35  */
36
37 #include <sys/types.h>
38 #include <sys/systm.h>
39 #include <sys/stat.h>
40 #include <sys/mman.h>
41 #include <vm/vm_page.h>
42 #include <assert.h>
43
44 /*
45  * A bcopy that works dring low level boot, before FP is working
46  */
47 void
48 ovbcopy(const void *src, void *dst, size_t len)
49 {
50         bcopy(src, dst, len);
51 }
52
53 void
54 bcopyi(const void *src, void *dst, size_t len)
55 {
56         bcopy(src, dst, len);
57 }
58
59 int
60 copystr(const void *kfaddr, void *kdaddr, size_t len, size_t *lencopied)
61 {
62         size_t i;
63
64         for (i = 0; i < len; ++i) {
65                 if ((((char *)kdaddr)[i] = ((const char *)kfaddr)[i]) == 0) {
66                         if (lencopied)
67                                 *lencopied = i + 1;
68                         return(0);
69                 }
70         }
71         return (ENAMETOOLONG);
72 }
73
74 /*
75  * Copies a NUL-terminated string from user space to kernel space.
76  * The number of bytes copied, including the terminator, is returned in
77  * (*res).
78  *
79  * Returns 0 on success, EFAULT or ENAMETOOLONG on failure.
80  */
81 int
82 copyinstr(const void *udaddr, void *kaddr, size_t len, size_t *res)
83 {
84         assert(0);
85         return (EFAULT);
86 }
87
88 /*
89  * Copy a binary buffer from user space to kernel space.
90  *
91  * Returns 0 on success, EFAULT on failure.
92  */
93 int
94 copyin (const void *udaddr, void *kaddr, size_t len)
95 {
96         assert(0);
97         return (EFAULT);
98 }
99
100 /*
101  * Copy a binary buffer from kernel space to user space.
102  *
103  * Returns 0 on success, EFAULT on failure.
104  */
105 int
106 copyout (const void *kaddr, void *udaddr, size_t len)
107 {
108         assert(0);
109         return (EFAULT);
110 }
111  
112 /*
113  * Fetch the byte at the specified user address.  Returns -1 on failure.
114  */
115 int
116 fubyte(const void *base)
117 {
118         assert(0);
119         return (EFAULT);
120 }
121
122 /*
123  * Store a byte at the specified user address.  Returns -1 on failure.
124  */
125 int
126 subyte (void *base, int byte)
127 {
128         assert(0);
129         return (EFAULT);
130 }
131
132 /*
133  * Fetch a word (integer, 32 bits) from user space
134  */
135 long
136 fuword (const void *base)
137 {
138         assert(0);
139         return (EFAULT);
140 }
141
142 /*
143  * Store a word (integer, 32 bits) to user space
144  */
145 int
146 suword (void *base, long word)
147 {
148         assert(0);
149         return (EFAULT);
150 }
151
152 /*
153  * Fetch an short word (16 bits) from user space
154  */
155 int
156 fusword (void *base)
157 {
158         assert(0);
159         return (EFAULT);
160 }
161
162 /*
163  * Store a short word (16 bits) to user space
164  */
165 int
166 susword (void *base, int word)
167 {
168         assert(0);
169         return (EFAULT);
170 }
171