Skip to content

Commit 9bc1f98

Browse files
committed
Adding freestanding stubs for MPS library and VM so that C library can be excluded.
1 parent 57b429e commit 9bc1f98

File tree

3 files changed

+99
-17
lines changed

3 files changed

+99
-17
lines changed

code/mps.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@
9696
#if defined(PLINTH) /* see CONFIG_PLINTH_NONE in config.h */
9797
#include "mpsliban.c"
9898
#include "mpsioan.c"
99+
/* FIXME: Is vman part of the plinth? Not really. Explain this. */
100+
#include "vman.c" /* malloc-based pseudo memory mapping */
99101
#endif
100102

101103
/* Generic ("ANSI") platform */
@@ -104,7 +106,6 @@
104106

105107
#include "lockan.c" /* generic locks */
106108
#include "than.c" /* generic threads manager */
107-
#include "vman.c" /* malloc-based pseudo memory mapping */
108109
#include "protan.c" /* generic memory protection */
109110
#include "prmcan.c" /* generic operating system mutator context */
110111
#include "prmcanan.c" /* generic architecture mutator context */

code/mpslibfs.c

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
*
77
* .purpose: The purpose of this code is to test at compile time
88
* whether the code MPS can be compiled as freestanding [FIXME: ref?]
9+
* with a command like::
10+
*
11+
* gcc -nostdlib -DCONFIG_PLINTH_NONE -DCONFIG_PF_ANSI \
12+
* --entry mps_lib_assert_fail mps.c mpslibfs.c vmfs.c
913
*
1014
* .readership: For MPS client application developers and MPS developers.
1115
* .sources: <design/lib>
@@ -112,22 +116,6 @@ mps_res_t mps_io_flush(mps_io_t mps_io)
112116
}
113117

114118

115-
/* main -- dummy entry point
116-
*
117-
* Main is included here so that a command like::
118-
*
119-
* gcc -nostdlib -DCONFIG_PLINTH_NONE -DCONFIG_PF_ANSI mps.c mpslibfs.c
120-
*
121-
* can run to completion of the linker and reveal external
122-
* dependencies.
123-
*/
124-
125-
int main(void)
126-
{
127-
return 0;
128-
}
129-
130-
131119
/* C. COPYRIGHT AND LICENSE
132120
*
133121
* Copyright (C) 2001-2023 Ravenbrook Limited <https://www.ravenbrook.com/>.

code/vmfs.c

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
/* vmfs.c: FREESTANDING VM: VIRTUAL MEMORY MAPPING STUB
2+
*
3+
* $Id$
4+
* Copyright (c) 2001-2023 Ravenbrook Limited. See end of file for license.
5+
*
6+
* .purpose: The purpose of this code is to test at compile time
7+
* whether the code MPS can be compiled as freestanding [FIXME: ref?]
8+
* with a command like::
9+
*
10+
* gcc -nostdlib -DCONFIG_PLINTH_NONE -DCONFIG_PF_ANSI \
11+
* --entry mps_lib_assert_fail mps.c mpslibfs.c vmfs.c
12+
*
13+
* .sources: design.mps.lib
14+
*/
15+
16+
#include "mpm.h"
17+
#include "vm.h"
18+
19+
SRCID(vmfs, "$Id$");
20+
21+
22+
Size PageSize(void)
23+
{
24+
NOTREACHED;
25+
}
26+
27+
28+
Res VMParamFromArgs(void *params, size_t paramSize, ArgList args)
29+
{
30+
NOTREACHED;
31+
}
32+
33+
34+
/* VMInit -- reserve some virtual address space, and create a VM structure */
35+
36+
Res VMInit(VM vm, Size size, Size grainSize, void *params)
37+
{
38+
NOTREACHED;
39+
}
40+
41+
42+
/* VMFinish -- release all address space and finish VM structure */
43+
44+
void VMFinish(VM vm)
45+
{
46+
NOTREACHED;
47+
}
48+
49+
50+
/* VMMap -- map the given range of memory */
51+
52+
Res VMMap(VM vm, Addr base, Addr limit)
53+
{
54+
NOTREACHED;
55+
}
56+
57+
58+
/* VMUnmap -- unmap the given range of memory */
59+
60+
void VMUnmap(VM vm, Addr base, Addr limit)
61+
{
62+
NOTREACHED;
63+
}
64+
65+
66+
/* C. COPYRIGHT AND LICENSE
67+
*
68+
* Copyright (C) 2001-2023 Ravenbrook Limited <https://www.ravenbrook.com/>.
69+
*
70+
* Redistribution and use in source and binary forms, with or without
71+
* modification, are permitted provided that the following conditions are
72+
* met:
73+
*
74+
* 1. Redistributions of source code must retain the above copyright
75+
* notice, this list of conditions and the following disclaimer.
76+
*
77+
* 2. Redistributions in binary form must reproduce the above copyright
78+
* notice, this list of conditions and the following disclaimer in the
79+
* documentation and/or other materials provided with the
80+
* distribution.
81+
*
82+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
83+
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
84+
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
85+
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
86+
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
87+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
88+
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
89+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
90+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
91+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
92+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
93+
*/

0 commit comments

Comments
 (0)