metadata.c (8b19d28d68a396b0263e3c13a559a31f70eb3b1d) metadata.c (bca9c87b6104219af35ae5ea4a6af098a1631bca)
1/*-
2 * Copyright (c) 1998 Michael Smith <msmith@freebsd.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 30 unchanged lines hidden (view full) ---

39#endif
40
41#ifdef __arm__
42#include <machine/elf.h>
43#endif
44#include <machine/metadata.h>
45
46#include "bootstrap.h"
1/*-
2 * Copyright (c) 1998 Michael Smith <msmith@freebsd.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 30 unchanged lines hidden (view full) ---

39#endif
40
41#ifdef __arm__
42#include <machine/elf.h>
43#endif
44#include <machine/metadata.h>
45
46#include "bootstrap.h"
47#include "modinfo.h"
47
48#ifdef LOADER_GELI_SUPPORT
49#include "geliboot.h"
50#endif
51
52static int
53md_getboothowto(char *kargs)
54{

--- 32 unchanged lines hidden (view full) ---

87 archsw.arch_copyin("", addr, 1);
88 addr++;
89 }
90 archsw.arch_copyin("", addr, 1);
91 addr++;
92 return(addr);
93}
94
48
49#ifdef LOADER_GELI_SUPPORT
50#include "geliboot.h"
51#endif
52
53static int
54md_getboothowto(char *kargs)
55{

--- 32 unchanged lines hidden (view full) ---

88 archsw.arch_copyin("", addr, 1);
89 addr++;
90 }
91 archsw.arch_copyin("", addr, 1);
92 addr++;
93 return(addr);
94}
95
95/*
96 * Copy module-related data into the load area, where it can be
97 * used as a directory for loaded modules.
98 *
99 * Module data is presented in a self-describing format. Each datum
100 * is preceded by a 32-bit identifier and a 32-bit size field.
101 *
102 * Currently, the following data are saved:
103 *
104 * MOD_NAME (variable) module name (string)
105 * MOD_TYPE (variable) module type (string)
106 * MOD_ARGS (variable) module parameters (string)
107 * MOD_ADDR sizeof(vm_offset_t) module load address
108 * MOD_SIZE sizeof(size_t) module size
109 * MOD_METADATA (variable) type-specific metadata
110 */
111
112static int align;
96static int align;
113
114#define MOD_ALIGN(l) roundup(l, align)
97#define MOD_ALIGN(l) roundup(l, align)
115#define COPY32(v, a, c) { \
116 uint32_t x = (v); \
117 if (c) \
118 archsw.arch_copyin(&x, a, sizeof(x)); \
119 a += sizeof(x); \
120}
121
98
122#define MOD_STR(t, a, s, c) { \
123 COPY32(t, a, c); \
124 COPY32(strlen(s) + 1, a, c) \
125 if (c) \
126 archsw.arch_copyin(s, a, strlen(s) + 1);\
127 a += MOD_ALIGN(strlen(s) + 1); \
128}
129
130#define MOD_NAME(a, s, c) MOD_STR(MODINFO_NAME, a, s, c)
131#define MOD_TYPE(a, s, c) MOD_STR(MODINFO_TYPE, a, s, c)
132#define MOD_ARGS(a, s, c) MOD_STR(MODINFO_ARGS, a, s, c)
133
134#define MOD_VAR(t, a, s, c) { \
135 COPY32(t, a, c); \
136 COPY32(sizeof(s), a, c); \
137 if (c) \
138 archsw.arch_copyin(&s, a, sizeof(s)); \
139 a += MOD_ALIGN(sizeof(s)); \
140}
141
142#define MOD_ADDR(a, s, c) MOD_VAR(MODINFO_ADDR, a, s, c)
143#define MOD_SIZE(a, s, c) MOD_VAR(MODINFO_SIZE, a, s, c)
144
145#define MOD_METADATA(a, mm, c) { \
146 COPY32(MODINFO_METADATA | mm->md_type, a, c);\
147 COPY32(mm->md_size, a, c); \
148 if (c) \
149 archsw.arch_copyin(mm->md_data, a, mm->md_size);\
150 a += MOD_ALIGN(mm->md_size); \
151}
152
153#define MOD_END(a, c) { \
154 COPY32(MODINFO_END, a, c); \
155 COPY32(0, a, c); \
156}
157
158static vm_offset_t
159md_copymodules(vm_offset_t addr, int kern64)
160{
161 struct preloaded_file *fp;
162 struct file_metadata *md;
163 uint64_t scratch64;
164 uint32_t scratch32;
165 int c;

--- 198 unchanged lines hidden ---
99static vm_offset_t
100md_copymodules(vm_offset_t addr, int kern64)
101{
102 struct preloaded_file *fp;
103 struct file_metadata *md;
104 uint64_t scratch64;
105 uint32_t scratch32;
106 int c;

--- 198 unchanged lines hidden ---