blob: fc91a4b9defd850b1ae3957df421051396d12267 [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
Ronald G. Minnich04c94de2016-11-06 20:51:18 -080030#include <string.h>
31#include <commonlib/configstring.h>
32
33void 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. */
42void 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
48const char *configstring(void)
49{
Ronald G. Minnich574df1b2016-11-06 20:54:20 -080050 uint32_t addr = *(uint32_t *)CONFIG_RISCV_CONFIGSTRING;
Ronald G. Minnich04c94de2016-11-06 20:51:18 -080051 return (const char *)(uintptr_t)addr;
52}