blob: 4eca6af39a054697843199dae54f23d18eb4fdca [file] [log] [blame]
Ronald G. Minnich04c94de2016-11-06 20:51:18 -08001/*
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
30#include <config.h>
Ronald G. Minnich04c94de2016-11-06 20:51:18 -080031#include <string.h>
32#include <commonlib/configstring.h>
33
34void query_mem(const char *config_string, uintptr_t *base, size_t *size)
35{
36 query_result res = query_config_string(config_string, "ram{0{addr");
37 *base = get_uint(res);
38 res = query_config_string(config_string, "ram{0{size");
39 *size = get_uint(res);
40}
41
42/* query_rtc returns the physical address of the rtc. */
43void query_rtc(const char *config_string, uintptr_t *mtime)
44{
45 query_result res = query_config_string(config_string, "rtc{addr");
46 *mtime = (uintptr_t)get_uint(res);
47}
48
49const char *configstring(void)
50{
Ronald G. Minnich574df1b2016-11-06 20:54:20 -080051 uint32_t addr = *(uint32_t *)CONFIG_RISCV_CONFIGSTRING;
Ronald G. Minnich04c94de2016-11-06 20:51:18 -080052 return (const char *)(uintptr_t)addr;
53}