]> Git Repo - u-boot.git/blame - include/os.h
sandbox: config: enable fdt and snprintf() options
[u-boot.git] / include / os.h
CommitLineData
7a9219c1
SG
1/*
2 * Copyright (c) 2011 The Chromium OS Authors.
3 * See file CREDITS for list of people who contributed to this
4 * project.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of
9 * the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
19 * MA 02111-1307 USA
20 */
21
22/*
23 * Operating System Interface
24 *
25 * This provides access to useful OS routines from the sandbox architecture
26 */
27
4f345d56
MF
28#ifndef __OS_H__
29#define __OS_H__
30
7a9219c1
SG
31/**
32 * Access to the OS read() system call
33 *
34 * \param fd File descriptor as returned by os_open()
35 * \param buf Buffer to place data
36 * \param count Number of bytes to read
37 * \return number of bytes read, or -1 on error
38 */
39ssize_t os_read(int fd, void *buf, size_t count);
40
41/**
42 * Access to the OS write() system call
43 *
44 * \param fd File descriptor as returned by os_open()
45 * \param buf Buffer containing data to write
46 * \param count Number of bytes to write
47 * \return number of bytes written, or -1 on error
48 */
49ssize_t os_write(int fd, const void *buf, size_t count);
50
e2dcefcb
MF
51/**
52 * Access to the OS lseek() system call
53 *
54 * \param fd File descriptor as returned by os_open()
55 * \param offset File offset (based on whence)
56 * \param whence Position offset is relative to (see below)
57 * \return new file offset
58 */
59off_t os_lseek(int fd, off_t offset, int whence);
60
61/* Defines for "whence" in os_lseek() */
62#define OS_SEEK_SET 0
63#define OS_SEEK_CUR 1
64#define OS_SEEK_END 2
65
7a9219c1
SG
66/**
67 * Access to the OS open() system call
68 *
69 * \param pathname Pathname of file to open
70 * \param flags Flags, like O_RDONLY, O_RDWR
71 * \return file descriptor, or -1 on error
72 */
73int os_open(const char *pathname, int flags);
74
75/**
76 * Access to the OS close() system call
77 *
78 * \param fd File descriptor to close
79 * \return 0 on success, -1 on error
80 */
81int os_close(int fd);
82
83/**
84 * Access to the OS exit() system call
85 *
86 * This exits with the supplied return code, which should be 0 to indicate
87 * success.
88 *
89 * @param exit_code exit code for U-Boot
90 */
91void os_exit(int exit_code);
ab06a758
MF
92
93/**
94 * Put tty into raw mode to mimic serial console better
95 */
96void os_tty_raw(int fd);
21899b10
MW
97
98/**
99 * Acquires some memory from the underlying os.
100 *
101 * \param length Number of bytes to be allocated
102 * \return Pointer to length bytes or NULL on error
103 */
104void *os_malloc(size_t length);
d99a6874
MW
105
106/**
107 * Access to the usleep function of the os
108 *
109 * \param usec Time to sleep in micro seconds
110 */
111void os_usleep(unsigned long usec);
112
113/**
114 * Gets a monotonic increasing number of nano seconds from the OS
115 *
116 * \return A monotonic increasing time scaled in nano seconds
117 */
118u64 os_get_nsec(void);
4f345d56
MF
119
120#endif
This page took 0.065665 seconds and 4 git commands to generate.