summaryrefslogtreecommitdiffstats
path: root/utils/regtools/desc_parser.hpp
blob: 908cff8940b4893f6088134dab0490af1dd3103e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/***************************************************************************
 *             __________               __   ___.
 *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
 *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
 *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
 *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
 *                     \/            \/     \/    \/            \/
 * $Id$
 *
 * Copyright (C) 2002 by Amaury Pouly
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
 * KIND, either express or implied.
 *
 ****************************************************************************/  
#ifndef __DESC_PARSER__
#define __DESC_PARSER__

#include <stdint.h>
#include <vector>
#include <string>

typedef uint32_t soc_addr_t;
typedef uint32_t soc_word_t;
typedef uint32_t soc_reg_flags_t;

const soc_addr_t SOC_NO_ADDR = 0xffffffff;
const soc_reg_flags_t REG_HAS_SCT = 1 << 0;

struct soc_reg_field_value_t
{
    std::string name;
    soc_word_t value;
};

struct soc_reg_field_t
{
    std::string name;
    unsigned first_bit, last_bit;

    soc_word_t bitmask() const
    {
        return ((1 << (last_bit - first_bit + 1)) - 1) << first_bit;
    }

    std::vector< soc_reg_field_value_t > values;
};

struct soc_reg_t
{
    std::string name;
    soc_addr_t addr;
    soc_reg_flags_t flags;

    std::vector< soc_reg_field_t > fields;
};

struct soc_multireg_t
{
    std::string name;
    soc_addr_t base;
    unsigned count;
    soc_addr_t offset;
    soc_reg_flags_t flags;

    std::vector< soc_reg_t > regs;
    std::vector< soc_reg_field_t > fields;
};

struct soc_dev_t
{
    std::string name;
    std::string long_name;
    std::string desc;
    soc_addr_t addr;

    std::vector< soc_multireg_t > multiregs;
    std::vector< soc_reg_t > regs;
};

struct soc_multidev_t
{
    std::string name;
    std::string long_name;
    std::string desc;

    std::vector< soc_dev_t > devs;
    std::vector< soc_multireg_t > multiregs;
    std::vector< soc_reg_t > regs;
};

struct soc_t
{
    std::string name;
    std::string desc;

    std::vector< soc_dev_t > devs;
    std::vector< soc_multidev_t > multidevs;
};

bool parse_soc_desc(const std::string& filename, std::vector< soc_t >& soc);

#endif /* __DESC_PARSER__ */