struct sandbox_state;
/**
+ * os_printf() - print directly to OS console
+ *
+ * @format: format string
+ */
+int os_printf(const char *format, ...);
+
+/**
* Access to the OS read() system call
*
* @fd: File descriptor as returned by os_open()
#define OS_SEEK_END 2
/**
+ * os_filesize() - Calculate the size of a file
+ *
+ * @fd: File descriptor as returned by os_open()
+ * Return: file size or negative error code
+ */
+int os_filesize(int fd);
+
+/**
* Access to the OS open() system call
*
* @pathname: Pathname of file to open
void os_exit(int exit_code) __attribute__((noreturn));
/**
+ * os_alarm() - access to the OS alarm() system call
+ *
+ * @seconds: number of seconds before the signal is sent
+ * Returns: number of seconds remaining until any previously scheduled alarm was
+ * due to be delivered; 0 if there was no previously scheduled alarm
+ */
+unsigned int os_alarm(unsigned int seconds);
+
+/**
+ * os_set_alarm_handler() - set handler for SIGALRM
+ *
+ * @handler: The handler function. Pass NULL for SIG_DFL.
+ */
+void os_set_alarm_handler(void (*handler)(int));
+
+/**
+ * os_raise_sigalrm() - do raise(SIGALRM)
+ */
+void os_raise_sigalrm(void);
+
+/**
* os_tty_raw() - put tty into raw mode to mimic serial console better
*
* @fd: File descriptor of stdin (normally 0)
* This follows the semantics of realloc(), so can perform an os_malloc() or
* os_free() depending on @ptr and @length.
*
- * Return: Pointer to reallocated memory or NULL if @length is 0
+ * @ptr: pointer to previously allocated memory of NULL
+ * @length: number of bytes to allocate
+ * Return: pointer to reallocated memory or NULL if @length is 0
*/
void *os_realloc(void *ptr, size_t length);
* @size: size of file is returned if no error
* Return: 0 on success or -1 if an error ocurred
*/
-int os_get_filesize(const char *fname, loff_t *size);
+int os_get_filesize(const char *fname, long long *size);
/**
* os_putc() - write a character to the controlling OS terminal
void os_puts(const char *str);
/**
+ * os_flush() - flush controlling OS terminal
+ *
+ * This bypasses the U-Boot console support and flushes directly the OS
+ * stdout file descriptor.
+ */
+void os_flush(void);
+
+/**
* os_write_ram_buf() - write the sandbox RAM buffer to a existing file
*
* @fname: filename to write memory to (simple binary format)
*
* @fname: place to put full path to U-Boot
* @maxlen: maximum size of @fname
+ * @use_img: select the 'u-boot.img' file instead of the 'u-boot' ELF file
+ * @cur_prefix: prefix of current executable, e.g. "spl" or "tpl"
+ * @next_prefix: prefix of executable to find, e.g. "spl" or ""
* Return: 0 if OK, -NOSPC if the filename is too large, -ENOENT if not found
*/
-int os_find_u_boot(char *fname, int maxlen);
+int os_find_u_boot(char *fname, int maxlen, bool use_img,
+ const char *cur_prefix, const char *next_prefix);
/**
* os_spl_to_uboot() - Run U-Boot proper
*/
int os_read_file(const char *name, void **bufp, int *sizep);
+/**
+ * os_map_file() - Map a file from the host filesystem into memory
+ *
+ * This can be useful when to provide a backing store for an emulated device
+ *
+ * @pathname: File pathname to map
+ * @os_flags: Flags, like OS_O_RDONLY, OS_O_RDWR
+ * @bufp: Returns buffer containing the file
+ * @sizep: Returns size of data
+ * Return: 0 if OK, -ve on error
+ */
+int os_map_file(const char *pathname, int os_flags, void **bufp, int *sizep);
+
+/**
+ * os_unmap() - Unmap a file previously mapped
+ *
+ * @buf: Mapped address
+ * @size: Size in bytes
+ * Return: 0 if OK, -ve on error
+ */
+int os_unmap(void *buf, int size);
+
/*
* os_find_text_base() - Find the text section in this running process
*