diff options
| author | Amaury Pouly <amaury.pouly@gmail.com> | 2012-11-14 12:35:21 +0100 |
|---|---|---|
| committer | Amaury Pouly <amaury.pouly@gmail.com> | 2012-11-14 12:35:21 +0100 |
| commit | 0c6b63479d83ada8782c751f779fef1271e2b874 (patch) | |
| tree | e2db6cdfa340b9c5e0d2a34b66c71bb45215abcf /utils/imxtools/regtools/desc_parser.hpp | |
| parent | 5ead8f3f441221f19830af2866a33a7f3f03423e (diff) | |
| download | rockbox-0c6b63479d83ada8782c751f779fef1271e2b874.zip rockbox-0c6b63479d83ada8782c751f779fef1271e2b874.tar.gz rockbox-0c6b63479d83ada8782c751f779fef1271e2b874.tar.bz2 rockbox-0c6b63479d83ada8782c751f779fef1271e2b874.tar.xz | |
imxtools: add regtools to work with register descriptions
These tools allow one to read a register description in a XML
file and to produce something useful out of it. Three example
programs are written:
- tester which simply prints the register tree
- headergen which produces a set of headers with the #define
- hwemulgen which produces something for the hwemul tool (to come)
Change-Id: I52573688b29d5faeaf64ce7c5ffe08ee8db3d33c
Diffstat (limited to 'utils/imxtools/regtools/desc_parser.hpp')
| -rw-r--r-- | utils/imxtools/regtools/desc_parser.hpp | 108 |
1 files changed, 108 insertions, 0 deletions
diff --git a/utils/imxtools/regtools/desc_parser.hpp b/utils/imxtools/regtools/desc_parser.hpp new file mode 100644 index 0000000..908cff8 --- /dev/null +++ b/utils/imxtools/regtools/desc_parser.hpp @@ -0,0 +1,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__ */
\ No newline at end of file |