blob: 40beb1659c6987cdf7a3354f8db522f78526c392 [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>
31#include <assert.h>
32#include <string.h>
33#include <commonlib/configstring.h>
34
35void query_mem(const char *config_string, uintptr_t *base, size_t *size)
36{
37 query_result res = query_config_string(config_string, "ram{0{addr");
38 *base = get_uint(res);
39 res = query_config_string(config_string, "ram{0{size");
40 *size = get_uint(res);
41}
42
43/* query_rtc returns the physical address of the rtc. */
44void query_rtc(const char *config_string, uintptr_t *mtime)
45{
46 query_result res = query_config_string(config_string, "rtc{addr");
47 *mtime = (uintptr_t)get_uint(res);
48}
49
50const char *configstring(void)
51{
52 uint32_t addr = *(uint32_t *)CONFIG_ARCH_CONFIGSTRING_RISCV;
53 return (const char *)(uintptr_t)addr;
54}