File indexing completed on 2025-05-11 08:24:06
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031 #include <grlib/ambapp.h>
0032
0033 struct ambapp_dev_find_match_arg {
0034 int index;
0035 int count;
0036 int type;
0037 void *dev;
0038 };
0039
0040
0041 static int ambapp_dev_find_match(struct ambapp_dev *dev, int index, void *arg)
0042 {
0043 struct ambapp_dev_find_match_arg *p = arg;
0044
0045 if (p->index == 0) {
0046
0047 if (p->type == DEV_APB_SLV) {
0048 *(struct ambapp_apb_info *)p->dev = *DEV_TO_APB(dev);
0049 p->dev = ((struct ambapp_apb_info *)p->dev)+1;
0050 } else {
0051 *(struct ambapp_ahb_info *)p->dev = *DEV_TO_AHB(dev);
0052 p->dev = ((struct ambapp_ahb_info *)p->dev)+1;
0053 }
0054 p->count--;
0055 if (p->count < 1)
0056 return 1;
0057 } else {
0058 p->index--;
0059 }
0060 return 0;
0061 }
0062
0063 int ambapp_find_apbslvs_next(struct ambapp_bus *abus, int vendor, int device, struct ambapp_apb_info *dev, int index, int maxno)
0064 {
0065 struct ambapp_dev_find_match_arg arg;
0066
0067 arg.index = index;
0068 arg.count = maxno;
0069 arg.type = DEV_APB_SLV;
0070 arg.dev = dev;
0071
0072 ambapp_for_each(abus, (OPTIONS_ALL|OPTIONS_APB_SLVS), vendor, device,
0073 ambapp_dev_find_match, &arg);
0074
0075 return maxno - arg.count;
0076 }
0077
0078 int ambapp_find_apbslv(struct ambapp_bus *abus, int vendor, int device, struct ambapp_apb_info *dev)
0079 {
0080 return ambapp_find_apbslvs_next(abus, vendor, device, dev, 0, 1);
0081 }
0082
0083 int ambapp_find_apbslv_next(struct ambapp_bus *abus, int vendor, int device, struct ambapp_apb_info *dev, int index)
0084 {
0085 return ambapp_find_apbslvs_next(abus, vendor, device, dev, index, 1);
0086 }
0087
0088 int ambapp_find_apbslvs(struct ambapp_bus *abus, int vendor, int device, struct ambapp_apb_info *dev, int maxno)
0089 {
0090 return ambapp_find_apbslvs_next(abus, vendor, device, dev, 0, maxno);
0091 }
0092
0093 int ambapp_get_number_apbslv_devices(struct ambapp_bus *abus, int vendor, int device)
0094 {
0095 return ambapp_dev_count(abus, (OPTIONS_ALL|OPTIONS_APB_SLVS), vendor, device);
0096 }
0097
0098 int ambapp_find_ahbslvs_next(struct ambapp_bus *abus, int vendor, int device, struct ambapp_ahb_info *dev, int index, int maxno)
0099 {
0100 struct ambapp_dev_find_match_arg arg;
0101
0102 arg.index = index;
0103 arg.count = maxno;
0104 arg.type = DEV_AHB_SLV;
0105 arg.dev = dev;
0106
0107 ambapp_for_each(abus, (OPTIONS_ALL|OPTIONS_AHB_SLVS), vendor, device,
0108 ambapp_dev_find_match, &arg);
0109
0110 return maxno - arg.count;
0111 }
0112
0113 int ambapp_find_ahbslv_next(struct ambapp_bus *abus, int vendor, int device, struct ambapp_ahb_info *dev, int index)
0114 {
0115 return ambapp_find_ahbslvs_next(abus, vendor, device, dev, index, 1);
0116 }
0117
0118 int ambapp_find_ahbslv(struct ambapp_bus *abus, int vendor, int device, struct ambapp_ahb_info *dev)
0119 {
0120 return ambapp_find_ahbslvs_next(abus, vendor, device, dev, 0, 1);
0121 }
0122
0123 int ambapp_find_ahbslvs(struct ambapp_bus *abus, int vendor, int device, struct ambapp_ahb_info *dev, int maxno)
0124 {
0125 return ambapp_find_ahbslvs_next(abus, vendor, device, dev, 0, maxno);
0126 }
0127
0128 int ambapp_get_number_ahbslv_devices(struct ambapp_bus *abus, int vendor, int device)
0129 {
0130 return ambapp_dev_count(abus, (OPTIONS_ALL|OPTIONS_AHB_SLVS), vendor, device);
0131 }