Ronald G. Minnich | 04c94de | 2016-11-06 20:51:18 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2013-2016, The Regents of the University of California |
| 3 | *(Regents). |
| 4 | * All Rights Reserved. |
| 5 | * |
| 6 | * Redistribution and use in source and binary forms, with or without |
| 7 | * modification, are permitted provided that the following conditions are met: |
| 8 | * 1. Redistributions of source code must retain the above copyright |
| 9 | * notice, this list of conditions and the following disclaimer. |
| 10 | * 2. Redistributions in binary form must reproduce the above copyright |
| 11 | * notice, this list of conditions and the following disclaimer in the |
| 12 | * documentation and/or other materials provided with the distribution. |
| 13 | * 3. Neither the name of the Regents nor the |
| 14 | * names of its contributors may be used to endorse or promote products |
| 15 | * derived from this software without specific prior written permission. |
| 16 | * |
| 17 | * IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, |
| 18 | * SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, |
| 19 | * ARISING |
| 20 | * OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS |
| 21 | * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 22 | * |
| 23 | * REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
| 24 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 25 | * PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED |
| 26 | * HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE |
| 27 | * MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
| 28 | */ |
| 29 | |
Ronald G. Minnich | 04c94de | 2016-11-06 20:51:18 -0800 | [diff] [blame] | 30 | #include <string.h> |
| 31 | #include <commonlib/configstring.h> |
| 32 | |
| 33 | void query_mem(const char *config_string, uintptr_t *base, size_t *size) |
| 34 | { |
| 35 | query_result res = query_config_string(config_string, "ram{0{addr"); |
| 36 | *base = get_uint(res); |
| 37 | res = query_config_string(config_string, "ram{0{size"); |
| 38 | *size = get_uint(res); |
| 39 | } |
| 40 | |
| 41 | /* query_rtc returns the physical address of the rtc. */ |
| 42 | void query_rtc(const char *config_string, uintptr_t *mtime) |
| 43 | { |
| 44 | query_result res = query_config_string(config_string, "rtc{addr"); |
| 45 | *mtime = (uintptr_t)get_uint(res); |
| 46 | } |
| 47 | |
| 48 | const char *configstring(void) |
| 49 | { |
Ronald G. Minnich | 574df1b | 2016-11-06 20:54:20 -0800 | [diff] [blame] | 50 | uint32_t addr = *(uint32_t *)CONFIG_RISCV_CONFIGSTRING; |
Ronald G. Minnich | 04c94de | 2016-11-06 20:51:18 -0800 | [diff] [blame] | 51 | return (const char *)(uintptr_t)addr; |
| 52 | } |