blob: 4cbcbd93a71ad0e1d2b4ec2264fd0366906a6c0b [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Simon Glasscd0684f2011-10-03 19:26:44 +00002/*
Simon Glass3196d752012-02-20 23:56:58 -05003 * Operating System Interface
4 *
5 * This provides access to useful OS routines for the sandbox architecture.
6 * They are kept in a separate file so we can include system headers.
7 *
Simon Glasscd0684f2011-10-03 19:26:44 +00008 * Copyright (c) 2011 The Chromium OS Authors.
Simon Glasscd0684f2011-10-03 19:26:44 +00009 */
10
Mike Frysinger999a5792012-01-19 22:57:29 -050011#ifndef __OS_H__
12#define __OS_H__
13
Simon Glassfb4b4e82013-05-19 16:45:35 -070014#include <linux/types.h>
15
Simon Glass504548f2015-04-20 12:37:22 -060016struct rtc_time;
Simon Glass8a3e0352012-02-15 15:51:16 -080017struct sandbox_state;
18
Simon Glasscd0684f2011-10-03 19:26:44 +000019/**
20 * Access to the OS read() system call
21 *
Heinrich Schuchardt1ffe0042020-10-27 20:29:27 +010022 * @fd: File descriptor as returned by os_open()
23 * @buf: Buffer to place data
24 * @count: Number of bytes to read
25 * Return: number of bytes read, or -1 on error
Simon Glasscd0684f2011-10-03 19:26:44 +000026 */
27ssize_t os_read(int fd, void *buf, size_t count);
28
29/**
30 * Access to the OS write() system call
31 *
Heinrich Schuchardt1ffe0042020-10-27 20:29:27 +010032 * @fd: File descriptor as returned by os_open()
33 * @buf: Buffer containing data to write
34 * @count: Number of bytes to write
35 * Return: number of bytes written, or -1 on error
Simon Glasscd0684f2011-10-03 19:26:44 +000036 */
37ssize_t os_write(int fd, const void *buf, size_t count);
38
39/**
Mike Frysinger60addac2011-10-25 13:02:58 +020040 * Access to the OS lseek() system call
41 *
Heinrich Schuchardt1ffe0042020-10-27 20:29:27 +010042 * @fd: File descriptor as returned by os_open()
43 * @offset: File offset (based on whence)
44 * @whence: Position offset is relative to (see below)
45 * Return: new file offset
Mike Frysinger60addac2011-10-25 13:02:58 +020046 */
47off_t os_lseek(int fd, off_t offset, int whence);
48
49/* Defines for "whence" in os_lseek() */
50#define OS_SEEK_SET 0
51#define OS_SEEK_CUR 1
52#define OS_SEEK_END 2
53
54/**
Simon Glass7b9cf84f2021-08-18 21:40:30 -060055 * os_filesize() - Calculate the size of a file
56 *
57 * @fd: File descriptor as returned by os_open()
58 * Return: file size or negative error code
59 */
60int os_filesize(int fd);
61
62/**
Simon Glasscd0684f2011-10-03 19:26:44 +000063 * Access to the OS open() system call
64 *
Heinrich Schuchardt1ffe0042020-10-27 20:29:27 +010065 * @pathname: Pathname of file to open
66 * @flags: Flags, like OS_O_RDONLY, OS_O_RDWR
67 * Return: file descriptor, or -1 on error
Simon Glasscd0684f2011-10-03 19:26:44 +000068 */
69int os_open(const char *pathname, int flags);
70
Simon Glass3196d752012-02-20 23:56:58 -050071#define OS_O_RDONLY 0
72#define OS_O_WRONLY 1
73#define OS_O_RDWR 2
74#define OS_O_MASK 3 /* Mask for read/write flags */
75#define OS_O_CREAT 0100
Simon Glassce55a112018-10-01 11:55:07 -060076#define OS_O_TRUNC 01000
Simon Glass3196d752012-02-20 23:56:58 -050077
Simon Glasscd0684f2011-10-03 19:26:44 +000078/**
Heinrich Schuchardt1ffe0042020-10-27 20:29:27 +010079 * os_close() - access to the OS close() system call
Simon Glasscd0684f2011-10-03 19:26:44 +000080 *
Heinrich Schuchardt1ffe0042020-10-27 20:29:27 +010081 * @fd: File descriptor to close
82 * Return: 0 on success, -1 on error
Simon Glasscd0684f2011-10-03 19:26:44 +000083 */
84int os_close(int fd);
85
86/**
Heinrich Schuchardt1ffe0042020-10-27 20:29:27 +010087 * os_unlink() - access to the OS unlink() system call
Stephen Warrencd5edba2014-03-01 22:18:00 -070088 *
Heinrich Schuchardt1ffe0042020-10-27 20:29:27 +010089 * @pathname: Path of file to delete
90 * Return: 0 for success, other for error
Stephen Warrencd5edba2014-03-01 22:18:00 -070091 */
92int os_unlink(const char *pathname);
93
94/**
Heinrich Schuchardt1ffe0042020-10-27 20:29:27 +010095 * os_exit() - access to the OS exit() system call
Simon Glasscd0684f2011-10-03 19:26:44 +000096 *
97 * This exits with the supplied return code, which should be 0 to indicate
98 * success.
99 *
Heinrich Schuchardt1ffe0042020-10-27 20:29:27 +0100100 * @exit_code: exit code for U-Boot
Simon Glasscd0684f2011-10-03 19:26:44 +0000101 */
Mike Frysingerbc036d32012-02-26 17:46:30 -0500102void os_exit(int exit_code) __attribute__((noreturn));
Mike Frysingera5baaee2011-10-26 00:21:29 +0000103
104/**
Heinrich Schuchardt1ffe0042020-10-27 20:29:27 +0100105 * os_tty_raw() - put tty into raw mode to mimic serial console better
Simon Glass678ef472014-02-27 13:26:22 -0700106 *
Heinrich Schuchardt1ffe0042020-10-27 20:29:27 +0100107 * @fd: File descriptor of stdin (normally 0)
108 * @allow_sigs: Allow Ctrl-C, Ctrl-Z to generate signals rather than
109 * be handled by U-Boot
Mike Frysingera5baaee2011-10-26 00:21:29 +0000110 */
Simon Glass678ef472014-02-27 13:26:22 -0700111void os_tty_raw(int fd, bool allow_sigs);
Matthias Weisserb5f7b472011-11-05 11:40:34 +0100112
113/**
Heinrich Schuchardt1ffe0042020-10-27 20:29:27 +0100114 * os_fs_restore() - restore the tty to its original mode
Simon Glass9c3b7d62015-05-10 21:07:27 -0600115 *
116 * Call this to restore the original terminal mode, after it has been changed
117 * by os_tty_raw(). This is an internal function.
118 */
119void os_fd_restore(void);
120
121/**
Heinrich Schuchardt1ffe0042020-10-27 20:29:27 +0100122 * os_malloc() - aquires some memory from the underlying os.
Matthias Weisserb5f7b472011-11-05 11:40:34 +0100123 *
Heinrich Schuchardt1ffe0042020-10-27 20:29:27 +0100124 * @length: Number of bytes to be allocated
Simon Glass4c902fa2021-02-06 09:57:32 -0700125 * Return: Pointer to length bytes or NULL if @length is 0 or on error
Matthias Weisserb5f7b472011-11-05 11:40:34 +0100126 */
127void *os_malloc(size_t length);
Matthias Weisser0d3dd142011-11-29 12:16:40 +0100128
129/**
Heinrich Schuchardt1ffe0042020-10-27 20:29:27 +0100130 * os_free() - free memory previous allocated with os_malloc()
Simon Glass1e6594c2013-11-10 10:26:57 -0700131 *
132 * This returns the memory to the OS.
133 *
Simon Glassedd094e2021-02-06 09:57:33 -0700134 * @ptr: Pointer to memory block to free. If this is NULL then this
135 * function does nothing
Simon Glass1e6594c2013-11-10 10:26:57 -0700136 */
Masahiro Yamadaee957282014-01-15 13:06:41 +0900137void os_free(void *ptr);
Simon Glass1e6594c2013-11-10 10:26:57 -0700138
139/**
Simon Glass4c902fa2021-02-06 09:57:32 -0700140 * os_realloc() - reallocate memory
141 *
142 * This follows the semantics of realloc(), so can perform an os_malloc() or
143 * os_free() depending on @ptr and @length.
144 *
Heinrich Schuchardt70e29992021-03-28 11:05:00 +0200145 * @ptr: pointer to previously allocated memory of NULL
146 * @length: number of bytes to allocate
147 * Return: pointer to reallocated memory or NULL if @length is 0
Simon Glass4c902fa2021-02-06 09:57:32 -0700148 */
149void *os_realloc(void *ptr, size_t length);
150
151/**
Heinrich Schuchardt1ffe0042020-10-27 20:29:27 +0100152 * os_usleep() - access to the usleep function of the os
Matthias Weisser0d3dd142011-11-29 12:16:40 +0100153 *
Heinrich Schuchardt1ffe0042020-10-27 20:29:27 +0100154 * @usec: time to sleep in micro seconds
Matthias Weisser0d3dd142011-11-29 12:16:40 +0100155 */
156void os_usleep(unsigned long usec);
157
158/**
159 * Gets a monotonic increasing number of nano seconds from the OS
160 *
Heinrich Schuchardt1ffe0042020-10-27 20:29:27 +0100161 * Return: a monotonic increasing time scaled in nano seconds
Matthias Weisser0d3dd142011-11-29 12:16:40 +0100162 */
Simon Glassfb4b4e82013-05-19 16:45:35 -0700163uint64_t os_get_nsec(void);
Mike Frysinger999a5792012-01-19 22:57:29 -0500164
Simon Glass8a3e0352012-02-15 15:51:16 -0800165/**
166 * Parse arguments and update sandbox state.
167 *
Heinrich Schuchardt1ffe0042020-10-27 20:29:27 +0100168 * @state: sandbox state to update
169 * @argc: argument count
170 * @argv: argument vector
171 * Return:
172 * * 0 if ok, and program should continue
173 * * 1 if ok, but program should stop
174 * * -1 on error: program should terminate
Simon Glass8a3e0352012-02-15 15:51:16 -0800175 */
176int os_parse_args(struct sandbox_state *state, int argc, char *argv[]);
177
Simon Glassf1c45c82012-12-26 09:53:34 +0000178/*
Heinrich Schuchardt1ffe0042020-10-27 20:29:27 +0100179 * enum os_dirent_t - type of directory entry
180 *
Simon Glassf1c45c82012-12-26 09:53:34 +0000181 * Types of directory entry that we support. See also os_dirent_typename in
182 * the C file.
183 */
184enum os_dirent_t {
Heinrich Schuchardt1ffe0042020-10-27 20:29:27 +0100185 /**
186 * @OS_FILET_REG: regular file
187 */
188 OS_FILET_REG,
189 /**
190 * @OS_FILET_LNK: symbolic link
191 */
192 OS_FILET_LNK,
193 /**
194 * @OS_FILET_DIR: directory
195 */
196 OS_FILET_DIR,
197 /**
198 * @OS_FILET_UNKNOWN: something else
199 */
200 OS_FILET_UNKNOWN,
201 /**
202 * @OS_FILET_COUNT: number of directory entry types
203 */
Simon Glassf1c45c82012-12-26 09:53:34 +0000204 OS_FILET_COUNT,
205};
206
Heinrich Schuchardt1ffe0042020-10-27 20:29:27 +0100207/**
208 * struct os_dirent_node - directory node
209 *
210 * A directory entry node, containing information about a single dirent
211 *
212 */
Simon Glassf1c45c82012-12-26 09:53:34 +0000213struct os_dirent_node {
Heinrich Schuchardt1ffe0042020-10-27 20:29:27 +0100214 /**
215 * @next: pointer to next node, or NULL
216 */
217 struct os_dirent_node *next;
218 /**
219 * @size: size of file in bytes
220 */
221 ulong size;
222 /**
223 * @type: type of entry
224 */
225 enum os_dirent_t type;
226 /**
227 * @name: name of entry
228 */
229 char name[0];
Simon Glassf1c45c82012-12-26 09:53:34 +0000230};
231
232/**
Heinrich Schuchardt1ffe0042020-10-27 20:29:27 +0100233 * os_dirent_ls() - get a directory listing
Simon Glassf1c45c82012-12-26 09:53:34 +0000234 *
235 * This allocates and returns a linked list containing the directory listing.
236 *
Heinrich Schuchardt1ffe0042020-10-27 20:29:27 +0100237 * @dirname: directory to examine
238 * @headp: on return pointer to head of linked list, or NULL if none
239 * Return: 0 if ok, -ve on error
Simon Glassf1c45c82012-12-26 09:53:34 +0000240 */
241int os_dirent_ls(const char *dirname, struct os_dirent_node **headp);
242
243/**
Heinrich Schuchardt1ffe0042020-10-27 20:29:27 +0100244 * os_dirent_free() - free directory list
Stefan Brünse0582842016-10-01 20:41:38 +0200245 *
246 * This frees a linked list containing a directory listing.
247 *
Heinrich Schuchardt1ffe0042020-10-27 20:29:27 +0100248 * @node: pointer to head of linked list
Stefan Brünse0582842016-10-01 20:41:38 +0200249 */
250void os_dirent_free(struct os_dirent_node *node);
251
252/**
Heinrich Schuchardt1ffe0042020-10-27 20:29:27 +0100253 * os_dirent_get_typename() - get the name of a directory entry type
Simon Glassf1c45c82012-12-26 09:53:34 +0000254 *
Heinrich Schuchardt1ffe0042020-10-27 20:29:27 +0100255 * @type: type to check
256 * Return:
257 * string containing the name of that type,
258 * or "???" if none/invalid
Simon Glassf1c45c82012-12-26 09:53:34 +0000259 */
260const char *os_dirent_get_typename(enum os_dirent_t type);
261
262/**
Heinrich Schuchardt1ffe0042020-10-27 20:29:27 +0100263 * os_get_filesize() - get the size of a file
Simon Glassf1c45c82012-12-26 09:53:34 +0000264 *
Heinrich Schuchardt1ffe0042020-10-27 20:29:27 +0100265 * @fname: filename to check
266 * @size: size of file is returned if no error
267 * Return: 0 on success or -1 if an error ocurred
Simon Glassf1c45c82012-12-26 09:53:34 +0000268 */
Suriyan Ramasami378da1032014-11-17 14:39:37 -0800269int os_get_filesize(const char *fname, loff_t *size);
Simon Glassf1c45c82012-12-26 09:53:34 +0000270
Simon Glass3e9fd242013-11-10 10:27:01 -0700271/**
Heinrich Schuchardt1ffe0042020-10-27 20:29:27 +0100272 * os_putc() - write a character to the controlling OS terminal
Simon Glass29d11432017-12-04 13:48:17 -0700273 *
274 * This bypasses the U-Boot console support and writes directly to the OS
275 * stdout file descriptor.
276 *
Heinrich Schuchardt1ffe0042020-10-27 20:29:27 +0100277 * @ch: haracter to write
Simon Glass29d11432017-12-04 13:48:17 -0700278 */
279void os_putc(int ch);
280
281/**
Heinrich Schuchardt1ffe0042020-10-27 20:29:27 +0100282 * os_puts() - write a string to the controlling OS terminal
Simon Glass29d11432017-12-04 13:48:17 -0700283 *
284 * This bypasses the U-Boot console support and writes directly to the OS
285 * stdout file descriptor.
286 *
Heinrich Schuchardt1ffe0042020-10-27 20:29:27 +0100287 * @str: string to write (note that \n is not appended)
Simon Glass29d11432017-12-04 13:48:17 -0700288 */
289void os_puts(const char *str);
290
291/**
Heinrich Schuchardt1ffe0042020-10-27 20:29:27 +0100292 * os_write_ram_buf() - write the sandbox RAM buffer to a existing file
Simon Glass9dd10bf2013-11-10 10:27:03 -0700293 *
Heinrich Schuchardt1ffe0042020-10-27 20:29:27 +0100294 * @fname: filename to write memory to (simple binary format)
295 * Return: 0 if OK, -ve on error
Simon Glass9dd10bf2013-11-10 10:27:03 -0700296 */
297int os_write_ram_buf(const char *fname);
298
299/**
Heinrich Schuchardt1ffe0042020-10-27 20:29:27 +0100300 * os_read_ram_buf() - read the sandbox RAM buffer from an existing file
Simon Glass9dd10bf2013-11-10 10:27:03 -0700301 *
Heinrich Schuchardt1ffe0042020-10-27 20:29:27 +0100302 * @fname: filename containing memory (simple binary format)
303 * Return: 0 if OK, -ve on error
Simon Glass9dd10bf2013-11-10 10:27:03 -0700304 */
305int os_read_ram_buf(const char *fname);
306
Simon Glass860b7d92014-02-27 13:26:15 -0700307/**
Heinrich Schuchardt1ffe0042020-10-27 20:29:27 +0100308 * os_jump_to_image() - jump to a new executable image
Simon Glass860b7d92014-02-27 13:26:15 -0700309 *
310 * This uses exec() to run a new executable image, after putting it in a
311 * temporary file. The same arguments and environment are passed to this
312 * new image, with the addition of:
313 *
314 * -j <filename> Specifies the filename the image was written to. The
315 * calling image may want to delete this at some point.
316 * -m <filename> Specifies the file containing the sandbox memory
317 * (ram_buf) from this image, so that the new image can
318 * have access to this. It also means that the original
319 * memory filename passed to U-Boot will be left intact.
320 *
Heinrich Schuchardt1ffe0042020-10-27 20:29:27 +0100321 * @dest: buffer containing executable image
322 * @size: size of buffer
323 * Return: 0 if OK, -ve on error
Simon Glass860b7d92014-02-27 13:26:15 -0700324 */
325int os_jump_to_image(const void *dest, int size);
326
Simon Glass504548f2015-04-20 12:37:22 -0600327/**
Heinrich Schuchardt1ffe0042020-10-27 20:29:27 +0100328 * os_find_u_boot() - determine the path to U-Boot proper
Simon Glass2c931ba2016-07-04 11:57:45 -0600329 *
330 * This function is intended to be called from within sandbox SPL. It uses
331 * a few heuristics to find U-Boot proper. Normally it is either in the same
332 * directory, or the directory above (since u-boot-spl is normally in an
333 * spl/ subdirectory when built).
334 *
Heinrich Schuchardt1ffe0042020-10-27 20:29:27 +0100335 * @fname: place to put full path to U-Boot
336 * @maxlen: maximum size of @fname
Simon Glassb90e4872021-03-07 17:35:13 -0700337 * @use_img: select the 'u-boot.img' file instead of the 'u-boot' ELF file
Simon Glass1cd06002021-07-05 16:32:45 -0600338 * @cur_prefix: prefix of current executable, e.g. "spl" or "tpl"
339 * @next_prefix: prefix of executable to find, e.g. "spl" or ""
Heinrich Schuchardt1ffe0042020-10-27 20:29:27 +0100340 * Return: 0 if OK, -NOSPC if the filename is too large, -ENOENT if not found
Simon Glass2c931ba2016-07-04 11:57:45 -0600341 */
Simon Glass1cd06002021-07-05 16:32:45 -0600342int os_find_u_boot(char *fname, int maxlen, bool use_img,
343 const char *cur_prefix, const char *next_prefix);
Simon Glass2c931ba2016-07-04 11:57:45 -0600344
345/**
346 * os_spl_to_uboot() - Run U-Boot proper
347 *
348 * When called from SPL, this runs U-Boot proper. The filename is obtained by
349 * calling os_find_u_boot().
350 *
Heinrich Schuchardt1ffe0042020-10-27 20:29:27 +0100351 * @fname: full pathname to U-Boot executable
352 * Return: 0 if OK, -ve on error
Simon Glass2c931ba2016-07-04 11:57:45 -0600353 */
354int os_spl_to_uboot(const char *fname);
355
356/**
Heinrich Schuchardt1ffe0042020-10-27 20:29:27 +0100357 * os_localtime() - read the current system time
Simon Glass504548f2015-04-20 12:37:22 -0600358 *
359 * This reads the current Local Time and places it into the provided
360 * structure.
361 *
Heinrich Schuchardt1ffe0042020-10-27 20:29:27 +0100362 * @rt: place to put system time
Simon Glass504548f2015-04-20 12:37:22 -0600363 */
364void os_localtime(struct rtc_time *rt);
365
Simon Glass5dccd152018-05-16 09:42:22 -0600366/**
Heinrich Schuchardt1ffe0042020-10-27 20:29:27 +0100367 * os_abort() - raise SIGABRT to exit sandbox (e.g. to debugger)
Simon Glassb7255ef2018-09-15 00:50:55 -0600368 */
Heinrich Schuchardt2165d0c2021-02-01 01:24:10 +0100369void os_abort(void) __attribute__((noreturn));
Simon Glass4e766c22018-10-01 21:12:32 -0600370
371/**
372 * os_mprotect_allow() - Remove write-protection on a region of memory
373 *
374 * The start and length will be page-aligned before use.
375 *
376 * @start: Region start
377 * @len: Region length in bytes
Heinrich Schuchardt1ffe0042020-10-27 20:29:27 +0100378 * Return: 0 if OK, -1 on error from mprotect()
Simon Glass4e766c22018-10-01 21:12:32 -0600379 */
380int os_mprotect_allow(void *start, size_t len);
381
Simon Glasscbfa8452018-10-01 11:55:08 -0600382/**
Heinrich Schuchardt1ffe0042020-10-27 20:29:27 +0100383 * os_write_file() - write a file to the host filesystem
Simon Glasscbfa8452018-10-01 11:55:08 -0600384 *
385 * This can be useful when debugging for writing data out of sandbox for
386 * inspection by external tools.
387 *
388 * @name: File path to write to
389 * @buf: Data to write
390 * @size: Size of data to write
Heinrich Schuchardt1ffe0042020-10-27 20:29:27 +0100391 * Return: 0 if OK, -ve on error
Simon Glasscbfa8452018-10-01 11:55:08 -0600392 */
393int os_write_file(const char *name, const void *buf, int size);
394
Simon Glass8d176d82018-11-06 15:21:25 -0700395/**
396 * os_read_file() - Read a file from the host filesystem
397 *
398 * This can be useful when reading test data into sandbox for use by test
399 * routines. The data is allocated using os_malloc() and should be freed by
400 * the caller.
401 *
402 * @name: File path to read from
403 * @bufp: Returns buffer containing data read
404 * @sizep: Returns size of data
Heinrich Schuchardt1ffe0042020-10-27 20:29:27 +0100405 * Return: 0 if OK, -ve on error
Simon Glass8d176d82018-11-06 15:21:25 -0700406 */
407int os_read_file(const char *name, void **bufp, int *sizep);
408
Simon Glasse4c25c82021-08-18 21:40:31 -0600409/**
410 * os_map_file() - Map a file from the host filesystem into memory
411 *
412 * This can be useful when to provide a backing store for an emulated device
413 *
414 * @pathname: File pathname to map
415 * @os_flags: Flags, like OS_O_RDONLY, OS_O_RDWR
416 * @bufp: Returns buffer containing the file
417 * @sizep: Returns size of data
418 * Return: 0 if OK, -ve on error
419 */
420int os_map_file(const char *pathname, int os_flags, void **bufp, int *sizep);
421
Simon Glass5c1fd582021-10-23 17:25:58 -0600422/**
423 * os_unmap() - Unmap a file previously mapped
424 *
425 * @buf: Mapped address
426 * @size: Size in bytes
427 * Return: 0 if OK, -ve on error
428 */
429int os_unmap(void *buf, int size);
430
Simon Glass752707a2019-04-08 13:20:41 -0600431/*
432 * os_find_text_base() - Find the text section in this running process
433 *
434 * This tries to find the address of the text section in this running process.
435 * It can be useful to map the address of functions to the address listed in
436 * the u-boot.map file.
437 *
Heinrich Schuchardt1ffe0042020-10-27 20:29:27 +0100438 * Return: address if found, else NULL
Simon Glass752707a2019-04-08 13:20:41 -0600439 */
440void *os_find_text_base(void);
441
Heinrich Schuchardt1c678442020-10-27 20:29:25 +0100442/**
443 * os_relaunch() - restart the sandbox
444 *
445 * This functions is used to implement the cold reboot of the sand box.
Heinrich Schuchardt1ffe0042020-10-27 20:29:27 +0100446 * @argv\[0] specifies the binary that is started while the calling process
Heinrich Schuchardt1c678442020-10-27 20:29:25 +0100447 * stops immediately. If the new binary cannot be started, the process is
448 * terminated and 1 is set as shell return code.
449 *
450 * The PID of the process stays the same. All file descriptors that have not
451 * been opened with O_CLOEXEC stay open including stdin, stdout, stderr.
452 *
453 * @argv: NULL terminated list of command line parameters
454 */
455void os_relaunch(char *argv[]);
456
Heinrich Schuchardt28eb5092020-11-12 00:29:56 +0100457/**
458 * os_setup_signal_handlers() - setup signal handlers
459 *
460 * Install signal handlers for SIGBUS and SIGSEGV.
461 *
462 * Return: 0 for success
463 */
464int os_setup_signal_handlers(void);
465
466/**
467 * os_signal_action() - handle a signal
468 *
469 * @sig: signal
470 * @pc: program counter
471 */
472void os_signal_action(int sig, unsigned long pc);
473
Heinrich Schuchardtc0d1a002020-12-30 18:07:48 +0100474/**
475 * os_get_time_offset() - get time offset
476 *
477 * Get the time offset from environment variable UBOOT_SB_TIME_OFFSET.
478 *
479 * Return: offset in seconds
480 */
481long os_get_time_offset(void);
482
483/**
484 * os_set_time_offset() - set time offset
485 *
486 * Save the time offset in environment variable UBOOT_SB_TIME_OFFSET.
487 *
488 * @offset: offset in seconds
489 */
490void os_set_time_offset(long offset);
491
Mike Frysinger999a5792012-01-19 22:57:29 -0500492#endif