world leader in high performance signal processing
Trace:

Differences

This shows you the differences between two versions of the page.

protocols:icc [2012/06/28 22:43]
steven.miao [SM_BAD_MSG] add endpoint query
protocols:icc [2013/03/13 22:42] (current)
sonicz [Cache policy]
Line 73: Line 73:
   typedef uint32_t sm_uint32_t;   typedef uint32_t sm_uint32_t;
   typedef void *sm_address_t;   typedef void *sm_address_t;
 +
 +===== Cache policy =====
 +One of the assumptions of the MCAPI/ICC protocol is that the payload buffer received on one core is located in the memory region managed(owned) by the other cores.
 +
 +Core 0 should set up write through CPLB entries for the memory region managed by core 1. So, The invalidate instruction on core 0 doesn’t flush dummy data in cache back to the MCAPI payload buffer sent by core 1 or drop unrelated data in the same cache line near the MCAPI payload boundary. What CPLB entries (WT/WB) are set up for the same memory region on core 1 doesn’t matter, because core 1 should flush the MCAPI payload buffer before sending. 
 +
 +For example:
 +^BF609 mem addr    ^ Owner ^ Core0 cache ^ Core1 cache ^
 +|0~0x3FFFFF        | Core0 | WB          | WT |
 +|0x400000~0x800000 | Core1 | WT          | WB |
 +
  
 ===== Atomic access ===== ===== Atomic access =====
Line 140: Line 151:
 **Message queues** are circular buffers containing SM_MSGQ_LEN fixed size messages. **Message queues** are circular buffers containing SM_MSGQ_LEN fixed size messages.
 <code> <code>
-  typedef struct sm_msg { 
-        sm_uint16_t dst_ep; 
-        sm_uint16_t src_ep; 
-        sm_uint32_t type; 
-        sm_address_t payload; 
-        sm_uint32_t length ; 
-  } sm_msg_t; 
- 
- 
   typedef struct {   typedef struct {
     sm_atomic_t sent;     sm_atomic_t sent;
Line 436: Line 438:
 </code> </code>
  
-The ID of a shared resource is unique among all kinds of resources. The supper 4 bits indicate the type of the shared resource, while the rest 12 bits is the index in the given type group. There are at most 16 (2^4) types and only 5 is defined yet. For each type, there could be at most 4096 (2^12) individual resources.+The ID of a shared resource is unique among all kinds of resources. The supper 4 bits indicate the type of the shared resource, while the rest 12 bits is the index in the given type group. There are at most 16 (2^4) types and only 5 is defined yet. For each type, there could be at most 4096 (2^12) individual resources. The SM_RES_MGR message use payload to pass resouce ID, and use length to point to a 32-bit resouce description data address if resouce type is RESMGR_TYPE_PERIPHERAL. 
 <code> <code>
 // resource types // resource types
Line 462: Line 465:
  
  
-Resouce description data should be put in the payload buffer of the message in following format.+Resource description data address should be put in the length of the message in following format.
 <code> <code>
 typedef struct { typedef struct {
-  uint8 label[32]; // owner name +  uint8_t label[32];         // resource device owner name 
-  uint16 count; // resource number in next array +  uint16_t count; // resource number in next array 
-  uint16 resources[1]; // first element of the resource ID array+  uint32_t resources_array; // address of the resource ID array
 } resources_t; } resources_t;
 </code> </code>
  
-The generic map of the peripheralsGPIOssystem IRQs and DMA channels to their ID should be defined for each arch. The resource sequence in the HRM can be one reference for the generic map. +Resource manager APIs declaration: 
 +<code> 
 +int sm_request_resource(uint32_t dst_cpuuint32_t resource_idresources_t *data) 
 +int sm_free_resource(uint32_t dst_cpu, uint32_t resource_id, resources_t *data) 
 +</code>
  
-=== Specifics for BF561 ===+==== peripherals type ==== 
 +For peripherals type, the peripheral name and list is passed by resouce description data. 
 +=== example to request/free peripherals type ===
  
-^Peripheral ID ^Peripheral in bf561 HRM^ +<code> 
-|0 |SPI0| + 
-|1 |PPI0| +unsigned short bfin_peripheral_list[] = {P_SPI1_SCK, P_SPI1_MISO, P_SPI1_MOSI, 0}; 
-|2 |PPI1| +resources_t bfin_peri_res = { 
-|3 |SPORT0| +        .label = "bfin-spi1", 
-|4 |SPORT1| +}; 
-|5 |UART0| + 
-|6 |TIMER0|+       bfin_peri_res.count = 3; 
 +        bfin_peri_res.resources_array = (uint32_t)bfin_peripheral_list; 
 + 
 +        COREB_DEBUG(1, "request resource id %s\n", bfin_peri_res.label); 
 +        ret = sm_request_resource(EP_RESMGR_SERVICE, RESMGR_ID(RESMGR_TYPE_PERIPHERAL, 0), &bfin_peri_res); 
 +        if (ret) { 
 +                COREB_DEBUG(1, "request peri resource failed\n"); 
 +        } 
 + 
 +        ret = sm_free_resource(EP_RESMGR_SERVICE, RESMGR_ID(RESMGR_TYPE_PERIPHERAL, 0), &bfin_peri_res); 
 +        if (ret) { 
 +                COREB_DEBUG(1, "free peri resource failed\n"); 
 +        } 
 + 
 +</code> 
 + 
 +==== GPIO, IRQ and DMA type ==== 
 +The generic map of the GPIOs, system IRQs and DMA channels to their ID should be defined for each arch. The resource sequence in the HRM can be one reference for the generic map.  
 + 
 +=== Specifics for BF561 ===
  
 ^GPIO ID ^GPIO in bf561 HRM  ^ ^GPIO ID ^GPIO in bf561 HRM  ^
Line 595: Line 623:
 |35 |IMDMA_MEM_STREAM1_SRC| |35 |IMDMA_MEM_STREAM1_SRC|
  
 +=== Specifics for BF609 ===
  
-=== An example to use resource manager protocol ===+^GPIO ID ^GPIO in bf609 HRM  ^ 
 +|0 |GPIO0| 
 +|1 |GPIO1| 
 +|... |...| 
 +|112 |GPIO112| 
 + 
 +^System IRQ ID ^System IRQ in b609 HRM^ 
 +|0 |IRQ_SEC_ERR| 
 +|1 |IRQ_CGU_EVT| 
 +|2 |IRQ_WATCH0| 
 +|3 |IRQ_WATCH1| 
 +|4 |IRQ_L2CTL0_ECC_ERR| 
 +|5 |IRQ_L2CTL0_ECC_WARN| 
 +|6 |IRQ_C0_DBL_FAULT| 
 +|7 |IRQ_C1_DBL_FAULT| 
 +|8 |IRQ_C0_HW_ERR| 
 +|9 |IRQ_C1_HW_ERR| 
 +|10 |IRQ_C0_NMI_L1_PARITY_ERR| 
 +|11 |IRQ_C1_NMI_L1_PARITY_ERR| 
 +|12 |IRQ_TIMER0| 
 +|13 |IRQ_TIMER1| 
 +|14 |IRQ_TIMER2| 
 +|15 |IRQ_TIMER3| 
 +|16 |IRQ_TIMER4| 
 +|17 |IRQ_TIMER5| 
 +|18 |IRQ_TIMER6| 
 +|19 |IRQ_TIMER7| 
 +|20 |IRQ_TIMER_STAT| 
 +|21 |IRQ_PINT0| 
 +|22 |IRQ_PINT1| 
 +|23 |IRQ_PINT2| 
 +|24 |IRQ_PINT3| 
 +|25 |IRQ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DEST| 
 +|25 |CH_MEM_STREAM2_SRC| 
 +|26 |CH_MEM_STREAM2_DEST| 
 +|27 |CH_MEM_STREAM3_SRC| 
 +|28 |CH_MEM_STREAM3_DEST| 
 +|29 |CH_EPPI0_CH0| 
 +|30 |CH_EPPI0_CH1| 
 +|31 |CH_EPPI2_CH0| 
 +|32 |CH_EPPI2_CH1| 
 +|33 |CH_EPPI1_CH0| 
 +|34 |CH_EPPI1_CH1| 
 +|35 |CH_PIXC_CH0| 
 +|36 |CH_PIXC_CH1| 
 +|37 |CH_PIXC_CH2| 
 +|38 |CH_PVP_CPDOB| 
 +|39 |CH_PVP_CPDOC| 
 +|40 |CH_PVP_CPSTAT| 
 +|41 |CH_PVP_CPCI| 
 +|42 |CH_PVP_MPDO| 
 +|43 |CH_PVP_MPDI| 
 +|44 |CH_PVP_MPSTAT| 
 +|45 |CH_PVP_MPCI| 
 +|46 |CH_PVP_CPDOA| 
 + 
 +=== An example request/free other resource type ===
 <code> <code>
-sm_msg_t res_request; 
-uint8 res_payload[100]; 
-resources_t *resp = res_payload; 
  
-strncpy(resp->;label, "test owner", 31); +ret = sm_request_resource(EP_RESMGR_SERVICE, RESMGR_ID(RESMGR_TYPE_GPIO, 40), 0); 
-resp->count = 3; +if (ret)  
-resp->resource[0] = RESMGR_ID(RESMGR_TYPE_GPIOPF0); +    COREB_DEBUG(1, "request resource failed\n"); 
-resp-&gt;resource[1] = RESMGR_ID(RESMGR_TYPE_GPIOPF4); +     
-resp-&gt;resource[2] = RESMGR_ID(RESMGR_TYPE_SYS_IRQ, PF0_PF15_A);+ret sm_request_resource(EP_RESMGR_SERVICE, RESMGR_ID(RESMGR_TYPE_SYS_IRQ52), 0); 
 +if (ret)  
 +    COREB_DEBUG(1, &quot;request resource failed\n"); 
 + 
 +ret sm_request_resource(EP_RESMGR_SERVICE, RESMGR_ID(RESMGR_TYPE_DMA20), 0); 
 +if (ret)  
 +    COREB_DEBUG(1, &quot;request resource failed\n");
  
-res_request.des_ep = EP_RESMGR_SERVICE+sm_free_resource(EP_RESMGR_SERVICE, RESMGR_ID(RESMGR_TYPE_GPIO40), 0); 
-res_request.src_ep = any_available_local_ep; // should be > EP_RES_MGR_MAX +sm_free_resource(EP_RESMGR_SERVICE, RESMGR_ID(RESMGR_TYPE_SYS_IRQ, 52), 0); 
-res_request.type = SM_MSG_TYPE(SM_RES_MGR_REQUESTSP_RES_MANAGER); +sm_free_resource(EP_RESMGR_SERVICE, RESMGR_ID(RESMGR_TYPE_DMA, 20), 0);
-res_request.payload = res_payload; +
-res_request.len = sizeof(struct resource_t+
-        + sizeof(uint16) * (resp->count - 1) ;+
 </code> </code>