Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
Simon Glass | b4a905e | 2011-10-10 08:22:14 +0000 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2011 The Chromium OS Authors. |
| 4 | * |
| 5 | * (C) Copyright 2002 |
| 6 | * Sysgo Real-Time Solutions, GmbH <www.elinos.com> |
| 7 | * Marius Groeger <mgroeger@sysgo.de> |
| 8 | * |
| 9 | * (C) Copyright 2002 |
| 10 | * Sysgo Real-Time Solutions, GmbH <www.elinos.com> |
| 11 | * Alex Zuepke <azu@sysgo.de> |
Simon Glass | b4a905e | 2011-10-10 08:22:14 +0000 | [diff] [blame] | 12 | */ |
| 13 | |
| 14 | #ifndef _U_BOOT_SANDBOX_H_ |
| 15 | #define _U_BOOT_SANDBOX_H_ |
| 16 | |
| 17 | /* board/.../... */ |
| 18 | int board_init(void); |
Simon Glass | b4a905e | 2011-10-10 08:22:14 +0000 | [diff] [blame] | 19 | |
Simon Glass | 0fc3c22 | 2012-02-26 17:38:50 -0500 | [diff] [blame] | 20 | /* start.c */ |
Simon Glass | 8a3e035 | 2012-02-15 15:51:16 -0800 | [diff] [blame] | 21 | int sandbox_early_getopt_check(void); |
Simon Glass | 0fc3c22 | 2012-02-26 17:38:50 -0500 | [diff] [blame] | 22 | int sandbox_main_loop_init(void); |
| 23 | |
Simon Glass | 0aa6349 | 2013-11-10 10:27:07 -0700 | [diff] [blame] | 24 | int cleanup_before_linux(void); |
| 25 | |
Simon Glass | b9ddbf4 | 2014-02-27 13:26:19 -0700 | [diff] [blame] | 26 | /* drivers/video/sandbox_sdl.c */ |
| 27 | int sandbox_lcd_sdl_early_init(void); |
| 28 | |
AKASHI Takahiro | 259dfe6 | 2019-10-04 13:45:18 +0900 | [diff] [blame] | 29 | struct udevice; |
| 30 | |
Simon Glass | 70778bc | 2015-03-05 12:25:26 -0700 | [diff] [blame] | 31 | /** |
| 32 | * pci_map_physmem() - map a PCI device into memory |
| 33 | * |
| 34 | * This is used on sandbox to map a device into memory so that it can be |
| 35 | * used with normal memory access. After this call, some part of the device's |
| 36 | * internal structure becomes visible. |
| 37 | * |
| 38 | * This function is normally called from sandbox's map_sysmem() automatically. |
| 39 | * |
| 40 | * @paddr: Physical memory address, normally corresponding to a PCI BAR |
| 41 | * @lenp: On entry, the size of the area to map, On exit it is updated |
| 42 | * to the size actually mapped, which may be less if the device |
| 43 | * has less space |
| 44 | * @devp: Returns the device which mapped into this space |
| 45 | * @ptrp: Returns a pointer to the mapped address. The device's space |
| 46 | * can be accessed as @lenp bytes starting here |
Heinrich Schuchardt | 47b4c02 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 47 | * Return: 0 if OK, -ve on error |
Simon Glass | 70778bc | 2015-03-05 12:25:26 -0700 | [diff] [blame] | 48 | */ |
| 49 | int pci_map_physmem(phys_addr_t paddr, unsigned long *lenp, |
| 50 | struct udevice **devp, void **ptrp); |
| 51 | |
| 52 | /** |
| 53 | * pci_unmap_physmem() - undo a memory mapping |
| 54 | * |
| 55 | * This must be called after pci_map_physmem() to undo the mapping. |
| 56 | * |
| 57 | * @paddr: Physical memory address, as passed to pci_map_physmem() |
| 58 | * @len: Size of area mapped, as returned by pci_map_physmem() |
| 59 | * @dev: Device to unmap, as returned by pci_map_physmem() |
Heinrich Schuchardt | 47b4c02 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 60 | * Return: 0 if OK, -ve on error |
Simon Glass | 70778bc | 2015-03-05 12:25:26 -0700 | [diff] [blame] | 61 | */ |
| 62 | int pci_unmap_physmem(const void *addr, unsigned long len, |
| 63 | struct udevice *dev); |
| 64 | |
| 65 | /** |
| 66 | * sandbox_set_enable_pci_map() - Enable / disable PCI address mapping |
| 67 | * |
| 68 | * Since address mapping involves calling every driver, provide a way to |
| 69 | * enable and disable this. It can be handled automatically by the emulator |
| 70 | * uclass, which knows if any emulators are currently active. |
| 71 | * |
| 72 | * If this is disabled, pci_map_physmem() will not be called from |
| 73 | * map_sysmem(). |
| 74 | * |
| 75 | * @enable: 0 to disable, 1 to enable |
| 76 | */ |
| 77 | void sandbox_set_enable_pci_map(int enable); |
| 78 | |
Simon Glass | 26b78b2 | 2015-02-27 22:06:34 -0700 | [diff] [blame] | 79 | /** |
Heinrich Schuchardt | 1c67844 | 2020-10-27 20:29:25 +0100 | [diff] [blame] | 80 | * sandbox_reset() - reset sandbox |
| 81 | * |
| 82 | * This functions implements the cold reboot of the sandbox. It relaunches the |
| 83 | * U-Boot binary with the same command line parameters as the original call. |
| 84 | * The PID of the process stays the same. All file descriptors that have not |
| 85 | * been opened with O_CLOEXEC stay open including stdin, stdout, stderr. |
| 86 | */ |
| 87 | void sandbox_reset(void); |
| 88 | |
Simon Glass | d860f22 | 2015-07-06 12:54:29 -0600 | [diff] [blame] | 89 | /* Exit sandbox (quit U-Boot) */ |
| 90 | void sandbox_exit(void); |
| 91 | |
Simon Glass | b4a905e | 2011-10-10 08:22:14 +0000 | [diff] [blame] | 92 | #endif /* _U_BOOT_SANDBOX_H_ */ |