Changes between Version 1 and Version 2 of mmc_device_api


Ignore:
Timestamp:
Jan 25, 2020, 11:26:28 PM (4 years ago)
Author:
alain
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • mmc_device_api

    v1 v2  
    1 TBD
     1= MMC device API =
     2
     3[[PageOutline]]
     4
     5== __A) General principles__ ==
     6
     7This device allows the kernel to access L2 caches, seen as internal peripherals distributed in all clusters, and containing addressable registers used for three different purposes:
     81. instrumentation,
     91. L2/L3 software cache coherence.
     101. addressing error signaling.
     11This device is called the ''MMC configuration interface''.
     12
     13The "kernel" API contains defines five command to access those three types of registers, details in section C.
     14
     15As all L2 caches can be accessed by any thread running in any cluster, a calling thread must get exclusive access to this MMC configuration interface. As these operations consume few cycles, and access conflicts are expected to be rare events, the calling threads can use a busy waiting strategy to get the device busy lock.  They do not register in the device waiting queue, and do not use any server thread.
     16
     17These MMC devices can rise an MMC_IRQ when a  bad address is detected for a write transaction. In this case, the error is reported by the ''ioc_driver_isr()'' function (ISR stand for Interrupt Service Routine).
     18
     19To access the various drivers, the IOC device defines a lower-level "driver" API, that is detailed in section D below.
     20
     21All IOC device structures and access functions are defined in the [https://www-soc.lip6.fr/trac/almos-mkh/browser/trunk/kernel/devices/dev_ioc.c  dev_ioc.c] et [https://www-soc.lip6.fr/trac/almos-mkh/browser/trunk/kernel/devices/dev_ioc.h dev_ioc.h] files.
     22
     23== __B) Initialisation__ ==
     24
     25The '''dev_mmc_init( chdev_t * chdev )''' function makes the following initializations :
     26 * This function initializes the driver specific fields in the generic MMC device descriptor.
     27 * It initialise the implementation specific MMC driver.
     28 * It links the MMC_IRQ to the local core identified by (lpid == 0), and enables this IRQ.
     29It must be executed once in any cluster containing an L2 cache.
     30
     31== __C) The "kernel" API__ ==
     32
     33All these operations are blocking (return only when the transfer is completed), and use all a polling policy.
     34
     35* The '''dev_mmc_inval( xptr_t buffer_xp , uint32_t nbytes )''' blocking function invalidates all cache lines covering a memory buffer in the physical address space, defined by the <buf_xp> extended pointer and by the <nbytes> argument. It can be executed by any thread in any cluster, because it uses remote accesses to access both the MMC chdev descriptor, and the MMC configuration interface.
     36 
     37* The '''dev_mmc_sync( xptr_t buffer_xp , uint32_t nbytes )''' blocking function forces the L2 cache to synchronize the L3 cache for all cache lines covering a memory buffer in the physical address space, defined by the <buf_xp> extended pointer and by the <nbytes> argument. It can be executed by any thread in any cluster, because it uses remote accesses to access both the MMC chdev descriptor, and the MMC configuration interface.
     38
     39* The '''dev_mmc_error_set( cxy_t cxy , uint32_t index , uint32_t wdata )''' function set the value <wdata> in one MMC error register identified by the <cxy> cluster identifier, and by the register <index>. It can be executed by any thread in any cluster, because it uses remote accesses  to access both the MMC chdev descriptor, and the MMC configuration interface.
     40
     41* The '''dev_mmc_error_get( cxy_t cxy , uint32_t index , uint32_t rdata )''' function returns in <rdata> the value contained in one MMC error register identified by the <cxy> cluster identifier, and by the register <index>. It can be executed by any thread in any cluster, because it uses remote accesses  to access both the MMC chdev descriptor, and the MMC configuration interface.
     42
     43* The '''dev_mmc_instru_get( cxy_t cxy , uint32_t index , uint32_t * rdata )''' function returns in <rdata> the value contained in one instrumentation MMC register identified by the <cxy> cluster identifier, and by the register <index>. It can be executed by any thread in any cluster, because it uses remote accesses  to access both the MMC chdev descriptor, and the MMC cache configuration interface.
     44
     45== __D) The "driver" API__ ==
     46
     47All MMC drivers must define three functions :
     48* void '''mmc_driver_init( chdev_t *ioc_chdev )'''
     49* void '''mmc_driver_cmd( xptr_t  thread_xp )'''
     50* void '''mmc_driver_isr( chdev_t * ioc_chdev )'''
     51
     52The ''mmc_driver_cmd()'' function arguments are actually defined in the ''mmc_command_t'' structure embedded in the client thread descriptor. One command contains four informations:
     53 - '''type''' : operation type (defined below).
     54 - '''buf_ptr''' : local pointer on buffer in kernel space (for INVAL/SYNC).
     55 - '''buf_size''' : number of bytes in buf_ptr buffer.
     56 - '''reg_index''' : register index in MMC peripheral.
     57 - '''reg_ptr''' : local pointer on source/destination buffer (for GET/SET).
     58The set of available instrumentation registers depend on the implementation.
     59
     60The five command types for the MMC driver(s) are the following:
     61 * '''MMC_CC_INVAL'''   : invalidate all cache lines covering a given buffer in L2 cache.
     62 * '''MMC_CC_SYNC'''    : synchronize all cache lines covering a given buffer to L3 cache.
     63 * '''MMC_ERROR_SET'''  : set a given error signaling register.
     64 * '''MMC_ERROR_GET'''  : return the content of a given error signaling register.
     65 * '''MMC_INSTRU_GET''' : return the content of a given instrumentation register.
     66
     67The '''mmc_driver_isr()''' must acknowledge the MMC_IRQ.
     68