blob: b417b8503adc9350366775dc0bd05b67b6a5f51d [file] [log] [blame]
Damjan Marion57d1ec02020-09-16 21:15:44 +02001/*
2 * Copyright (c) 2020 Cisco and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16#include <vppinfra/clib.h>
17#include <vppinfra/mem.h>
18#include <vppinfra/time.h>
19#include <vppinfra/format.h>
20#include <vppinfra/clib_error.h>
21
22clib_mem_main_t clib_mem_main;
23
Damjan Marion6bfd0762020-09-11 22:16:53 +020024void *
25clib_mem_vm_map (void *base, uword size, clib_mem_page_sz_t log2_page_sz,
26 char *fmt, ...)
27{
28 va_list va;
29 void *rv;
30 u8 *s;
31
32 va_start (va, fmt);
33 s = va_format (0, fmt, &va);
34 vec_add1 (s, 0);
35 rv = clib_mem_vm_map_internal (base, log2_page_sz, size, -1, 0, (char *) s);
36 va_end (va);
37 vec_free (s);
38 return rv;
39}
40
41void *
42clib_mem_vm_map_stack (uword size, clib_mem_page_sz_t log2_page_sz,
43 char *fmt, ...)
44{
45 va_list va;
46 void *rv;
47 u8 *s;
48
49 va_start (va, fmt);
50 s = va_format (0, fmt, &va);
51 vec_add1 (s, 0);
52 rv = clib_mem_vm_map_internal (0, log2_page_sz, size, -1, 0, (char *) s);
53 va_end (va);
54 vec_free (s);
55 return rv;
56}
57
58void *
59clib_mem_vm_map_shared (void *base, uword size, int fd, uword offset,
60 char *fmt, ...)
61{
62 va_list va;
63 void *rv;
64 u8 *s;
65 va_start (va, fmt);
66 s = va_format (0, fmt, &va);
67 vec_add1 (s, 0);
68 rv = clib_mem_vm_map_internal (base, 0, size, fd, offset, (char *) s);
69 va_end (va);
70 vec_free (s);
71 return rv;
72}
73
Damjan Marion57d1ec02020-09-16 21:15:44 +020074/*
75 * fd.io coding-style-patch-verification: ON
76 *
77 * Local Variables:
78 * eval: (c-set-style "gnu")
79 * End:
80 */