xref: /rk3399_rockchip-uboot/include/os.h (revision 7a9219c17a6a15bfa96a87b352837be71b6738f6)
1*7a9219c1SSimon Glass /*
2*7a9219c1SSimon Glass  * Copyright (c) 2011 The Chromium OS Authors.
3*7a9219c1SSimon Glass  * See file CREDITS for list of people who contributed to this
4*7a9219c1SSimon Glass  * project.
5*7a9219c1SSimon Glass  *
6*7a9219c1SSimon Glass  * This program is free software; you can redistribute it and/or
7*7a9219c1SSimon Glass  * modify it under the terms of the GNU General Public License as
8*7a9219c1SSimon Glass  * published by the Free Software Foundation; either version 2 of
9*7a9219c1SSimon Glass  * the License, or (at your option) any later version.
10*7a9219c1SSimon Glass  *
11*7a9219c1SSimon Glass  * This program is distributed in the hope that it will be useful,
12*7a9219c1SSimon Glass  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13*7a9219c1SSimon Glass  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14*7a9219c1SSimon Glass  * GNU General Public License for more details.
15*7a9219c1SSimon Glass  *
16*7a9219c1SSimon Glass  * You should have received a copy of the GNU General Public License
17*7a9219c1SSimon Glass  * along with this program; if not, write to the Free Software
18*7a9219c1SSimon Glass  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
19*7a9219c1SSimon Glass  * MA 02111-1307 USA
20*7a9219c1SSimon Glass  */
21*7a9219c1SSimon Glass 
22*7a9219c1SSimon Glass /*
23*7a9219c1SSimon Glass  * Operating System Interface
24*7a9219c1SSimon Glass  *
25*7a9219c1SSimon Glass  * This provides access to useful OS routines from the sandbox architecture
26*7a9219c1SSimon Glass  */
27*7a9219c1SSimon Glass 
28*7a9219c1SSimon Glass /**
29*7a9219c1SSimon Glass  * Access to the OS read() system call
30*7a9219c1SSimon Glass  *
31*7a9219c1SSimon Glass  * \param fd	File descriptor as returned by os_open()
32*7a9219c1SSimon Glass  * \param buf	Buffer to place data
33*7a9219c1SSimon Glass  * \param count	Number of bytes to read
34*7a9219c1SSimon Glass  * \return number of bytes read, or -1 on error
35*7a9219c1SSimon Glass  */
36*7a9219c1SSimon Glass ssize_t os_read(int fd, void *buf, size_t count);
37*7a9219c1SSimon Glass 
38*7a9219c1SSimon Glass /**
39*7a9219c1SSimon Glass  * Access to the OS write() system call
40*7a9219c1SSimon Glass  *
41*7a9219c1SSimon Glass  * \param fd	File descriptor as returned by os_open()
42*7a9219c1SSimon Glass  * \param buf	Buffer containing data to write
43*7a9219c1SSimon Glass  * \param count	Number of bytes to write
44*7a9219c1SSimon Glass  * \return number of bytes written, or -1 on error
45*7a9219c1SSimon Glass  */
46*7a9219c1SSimon Glass ssize_t os_write(int fd, const void *buf, size_t count);
47*7a9219c1SSimon Glass 
48*7a9219c1SSimon Glass /**
49*7a9219c1SSimon Glass  * Access to the OS open() system call
50*7a9219c1SSimon Glass  *
51*7a9219c1SSimon Glass  * \param pathname	Pathname of file to open
52*7a9219c1SSimon Glass  * \param flags		Flags, like O_RDONLY, O_RDWR
53*7a9219c1SSimon Glass  * \return file descriptor, or -1 on error
54*7a9219c1SSimon Glass  */
55*7a9219c1SSimon Glass int os_open(const char *pathname, int flags);
56*7a9219c1SSimon Glass 
57*7a9219c1SSimon Glass /**
58*7a9219c1SSimon Glass  * Access to the OS close() system call
59*7a9219c1SSimon Glass  *
60*7a9219c1SSimon Glass  * \param fd	File descriptor to close
61*7a9219c1SSimon Glass  * \return 0 on success, -1 on error
62*7a9219c1SSimon Glass  */
63*7a9219c1SSimon Glass int os_close(int fd);
64*7a9219c1SSimon Glass 
65*7a9219c1SSimon Glass /**
66*7a9219c1SSimon Glass  * Access to the OS exit() system call
67*7a9219c1SSimon Glass  *
68*7a9219c1SSimon Glass  * This exits with the supplied return code, which should be 0 to indicate
69*7a9219c1SSimon Glass  * success.
70*7a9219c1SSimon Glass  *
71*7a9219c1SSimon Glass  * @param exit_code	exit code for U-Boot
72*7a9219c1SSimon Glass  */
73*7a9219c1SSimon Glass void os_exit(int exit_code);
74