Skip to content
This repository has been archived by the owner on May 11, 2018. It is now read-only.

Commit

Permalink
added --devices flag for mem-mapped device support
Browse files Browse the repository at this point in the history
  • Loading branch information
iadgovuser3 committed Aug 7, 2015
1 parent ac97941 commit a00204d
Show file tree
Hide file tree
Showing 13 changed files with 345 additions and 161 deletions.
5 changes: 3 additions & 2 deletions README.md
Expand Up @@ -68,10 +68,10 @@ procedure has completed.
### Features/Limitations
------------------------
* Multi-core support
* Memory-mapped registers are currently not supported
* Memory-mapped system registers are currently not supported
* Only EL0/EL1 are supported
* Support for Cortex A7/A15/A53/A57
* Experimental GICv2 support
* Support for memory-mapped devices

* This application reads only a small portion of the available system
registers on an ARM CPU. Please refer to the ARMv7A and ARMv8A Architecture
Expand Down Expand Up @@ -202,6 +202,7 @@ Usage: maplesyrup --<register|group|bitfield|all> <NAME or ID> --arch=<ARCH> --i
--showfail - show all results regardless of success
--el0 - force execution at pl0
--el1 - force execution at pl1
--devices - include memory-mapped devices (memory intensive)
--show_groups - shows all valid functional groups
--show_bitfields - shows all valid bitfields
--show_registers - shows all valid register
Expand Down
36 changes: 28 additions & 8 deletions common/parse.h
Expand Up @@ -76,9 +76,10 @@ typedef struct ms_data_cpu

typedef struct bitfield_info
{
unsigned int range; // greater or equal to than 1
unsigned int bitfield_code; // bitfield
unsigned int ioctl_code; // register level
unsigned int range; // greater or equal to than 1 (applies to MM intf only)
//unsigned int field_partition; //
int uid; // bitfield unique id
unsigned int register_uid; // register unique id
unsigned int ppl; // preferred privilege level
unsigned int rightshift; // number of right bitshifts
unsigned int mask; // mask to apply after right bitshift
Expand Down Expand Up @@ -121,7 +122,7 @@ typedef struct match_info
unsigned int implementation;
unsigned char functional_group[PARSE_MAX_FUNCTIONAL];
unsigned char register_name[PARSE_MAX_REGISTER];
unsigned int bitfield_code;
unsigned int uid;
unsigned int pl; // override preferred pl
unsigned int noparse;
unsigned int cpu;
Expand All @@ -133,7 +134,7 @@ typedef struct match_info
typedef struct results_info
{
list_element list;
unsigned int ioctl_code;
unsigned int register_uid;
unsigned int uid;
unsigned int ppl;
unsigned int pl;
Expand All @@ -147,15 +148,15 @@ typedef struct results_info
typedef struct used_ioctl
{
list_element list;
unsigned int ioctl_code;
unsigned int register_uid;
unsigned int cpu;
unsigned int partnumber;
} used_ioctl;

typedef struct ioctl_result
{
list_element list;
unsigned int ioctl_code;
unsigned int register_uid;
unsigned long long val64;
unsigned int low;
unsigned int high;
Expand Down Expand Up @@ -392,7 +393,6 @@ enum
MS_SYSREG_FPSR,
MS_SYSREG_NZCV,
MS_SYSREG_SPSEL,

};

/* GICv2 CPU Interface */
Expand Down Expand Up @@ -425,6 +425,26 @@ enum
#define MS_GIC_GICD_IGROUPR 0x80 // ranged
#define MS_GIC_GICD_ISENABLER 0x100 // ranged
#define MS_GIC_GICD_ISPENDR 0x200 // ranged
#define MS_GIC_GICD_ICPENDR 0x280 // ranged
#define MS_GIC_GICD_ISACTIVER 0x300 // ranged
#define MS_GIC_GICD_ICACTIVER 0x380 // ranged
#define MS_GIC_GICD_IPRIORITYR 0x400 // ranged
#define MS_GIC_GICD_RESERVED_02 0x7FC // ranged
#define MS_GIC_GICD_ITARGETSR 0x800 // ranged
#define MS_GIC_GICD_RESERVED_03 0xBFC // ranged
#define MS_GIC_GICD_ICFGR 0xC00 // ranged
#define MS_GIC_GICD_IMP_DEF_01 0xD00 // ranged
#define MS_GIC_GICD_NSACR 0xE00 // ranged
#define MS_GIC_GICD_SGIR 0xF00
#define MS_GIC_GICD_RESERVED_04 0xF04 // ranged
#define MS_GIC_GICD_CPENDSGIR 0xF10 // ranged
#define MS_GIC_GICD_SPENDSGIR 0xF20 // ranged
#define MS_GIC_GICD_RESERVED_05 0xF30 // ranged
#define MS_GIC_GICD_IDENT 0xFD0 // ranged
#define MS_GIC_GICD_ICPIDR2 0xFE8 // ranged




/*
#define MS_GIC_GICD_RESERVED_01 0x10
Expand Down
20 changes: 14 additions & 6 deletions frontend/entrypoint.c
Expand Up @@ -31,6 +31,7 @@ int flag_fb_show_info = 0;
int flag_fb_showerrors = 0;
int flag_fb_noparse = 0;
int flag_fb_calc = 0;
int flag_fb_devices = 0;

static struct option long_options[] =
{
Expand All @@ -47,9 +48,10 @@ static struct option long_options[] =
{ "bitfield", no_argument, &flag_fb_bitfield, 1 },
{ "all", no_argument, &flag_fb_all, 1 },
{ "noparse", no_argument, &flag_fb_noparse, 1 },
{ "showfail", no_argument, &flag_fb_showerrors, 1 },
{ "showfail", no_argument, &flag_fb_showerrors, 1 },
{ "el0", no_argument, &flag_fb_el0, 1 },
{ "el1", no_argument, &flag_fb_el1, 1 },
{ "el1", no_argument, &flag_fb_el1, 1 },
{ "devices", no_argument, &flag_fb_devices, 1 },
{ "show_groups", no_argument, &flag_fb_show_info, FLAG_SHOW_GROUPS },
{ "show_bitfields", no_argument, &flag_fb_show_info, FLAG_SHOW_BITFIELDS },
{ "show_registers", no_argument, &flag_fb_show_info, FLAG_SHOW_REGISTERS },
Expand Down Expand Up @@ -77,6 +79,7 @@ print_usage(void)
{ long_options, "show all results regardless of success" },
{ long_options, "force execution at pl0" },
{ long_options, "force execution at pl1" },
{ long_options, "include memory-mapped devices (memory intensive)" },
{ long_options, "shows all valid functional groups" },
{ long_options, "shows all valid bitfields" },
{ long_options, "shows all valid register" },
Expand Down Expand Up @@ -331,7 +334,7 @@ main(int argc, char ** argv)
switch(flag_fb_show_info)
{
case FLAG_SHOW_GROUPS:
ms_get_groups(&toshow);
ms_get_groups(&toshow, flag_fb_devices);
no_results(toshow);
for (i = 0; i < ms_get_size(toshow); ++i)
{
Expand All @@ -340,7 +343,7 @@ main(int argc, char ** argv)
ms_free_result(&toshow);
break;
case FLAG_SHOW_BITFIELDS:
ms_get_bitfields(&toshow);
ms_get_bitfields(&toshow, flag_fb_devices);
no_results(toshow);
for (i = 0; i < ms_get_size(toshow); ++i)
{
Expand All @@ -353,7 +356,7 @@ main(int argc, char ** argv)
ms_free_result(&toshow);
break;
case FLAG_SHOW_REGISTERS:
ms_get_registers(&toshow);
ms_get_registers(&toshow, flag_fb_devices);
no_results(toshow);
for (i = 0; i < ms_get_size(toshow); ++i)
{
Expand All @@ -378,6 +381,7 @@ main(int argc, char ** argv)
arg_core,
ppl,
flag_fb_noparse,
flag_fb_devices,
&output) != 0)
{
goto done;
Expand All @@ -394,6 +398,7 @@ main(int argc, char ** argv)
arg_core,
ppl,
flag_fb_noparse,
flag_fb_devices,
&output) != 0)
{
goto done;
Expand All @@ -413,6 +418,7 @@ main(int argc, char ** argv)
ppl,
flag_fb_noparse,
arg_calc,
flag_fb_devices,
&output) != 0)
{
goto done;
Expand All @@ -427,6 +433,7 @@ main(int argc, char ** argv)
ppl,
flag_fb_noparse,
NULL,
flag_fb_devices,
&output) != 0)
{
goto done;
Expand All @@ -436,7 +443,7 @@ main(int argc, char ** argv)
}
else if (flag_fb_all)
{
ms_get_groups(&toshow);
ms_get_groups(&toshow, flag_fb_devices);
for (i = 0; i < ms_get_size(toshow); ++i)
{
if (ms_find_by_group(arg_arch,
Expand All @@ -445,6 +452,7 @@ main(int argc, char ** argv)
arg_core,
ppl,
flag_fb_noparse,
flag_fb_devices,
&output) != 0)
{
goto done;
Expand Down
9 changes: 6 additions & 3 deletions lib/include/maplesyrup.h
Expand Up @@ -72,6 +72,7 @@ int ms_find_by_bitfield(char * arch,
int cpu,
unsigned int pl,
unsigned int noparse,
int include_devices,
ms_bitfield_info ** results_out);

/******************************************************
Expand All @@ -92,6 +93,7 @@ int ms_find_by_register(char * arch,
unsigned int pl,
unsigned int noparse,
char * calc_value,
int include_devices,
ms_bitfield_info ** list_out);

/******************************************************
Expand All @@ -111,6 +113,7 @@ int ms_find_by_group(char * arch,
int cpu,
unsigned int pl,
unsigned int noparse,
int include_devices,
ms_bitfield_info ** list_out);


Expand All @@ -122,7 +125,7 @@ int ms_find_by_group(char * arch,
* @return 0 on success, -1 on error
*
* ***************************************************/
int ms_get_groups(ms_bitfield_info ** list_out);
int ms_get_groups(ms_bitfield_info ** list_out, int include_devices);

/******************************************************
* Search tables for all entered register names
Expand All @@ -132,7 +135,7 @@ int ms_get_groups(ms_bitfield_info ** list_out);
* @return 0 on success, -1 on error
*
* ***************************************************/
int ms_get_registers(ms_bitfield_info ** list_out);
int ms_get_registers(ms_bitfield_info ** list_out, int include_devices);

/******************************************************
* Search tables for all valid bitfield ids
Expand All @@ -142,7 +145,7 @@ int ms_get_registers(ms_bitfield_info ** list_out);
* @return 0 on success, -1 on error
*
* ***************************************************/
int ms_get_bitfields(ms_bitfield_info ** list_out);
int ms_get_bitfields(ms_bitfield_info ** list_out, int include_devices);

/******************************************************
* Free the memory allocated by find and get
Expand Down
2 changes: 1 addition & 1 deletion lib/src/Makefile.am
Expand Up @@ -6,7 +6,7 @@ libmaplesyrup_la_SOURCES += bitfields/bitfield_cortex-a57.c
libmaplesyrup_la_SOURCES += bitfields/bitfield_cortex-a53.c
libmaplesyrup_la_SOURCES += bitfields/bitfield_cortex-a15.c
libmaplesyrup_la_SOURCES += bitfields/bitfield_cortex-a7.c
libmaplesyrup_la_SOURCES += bitfields/bitfield_gicv2.c
libmaplesyrup_la_SOURCES += bitfields/bitfield_gicv2.c
libmaplesyrup_la_SOURCES += bitfields/bitfield_armv7a.h
libmaplesyrup_la_SOURCES += bitfields/bitfield_armv8a.h
libmaplesyrup_la_SOURCES += bitfields/bitfield_cortex-a7.h
Expand Down

0 comments on commit a00204d

Please sign in to comment.