source: trunk/softs/tsar_boot/drivers/reset_inval.c @ 929

Last change on this file since 929 was 911, checked in by alain, 10 years ago

The reset_buf_invalidate() function has been modified
to comply with the removing of the hard lock in the vci_mem_cache configuration interface.

File size: 1.6 KB
RevLine 
[758]1/**
2 * \file   reset_inval.c
3 * \date   December 14, 2014
4 * \author Cesar Fuguet
5 */
6
7#include <reset_inval.h>
8#include <io.h>
9#include <defs.h>
10
11#ifndef SEG_MMC_BASE
12#   error "SEG_MMC_BASE constant must be defined in the hard_config.h file"
13#endif
14
15static int* const mcc_address = (int* const)SEG_MMC_BASE;
16
17enum memc_registers
18{
[911]19    MCC_ADDR_LO   = 0,
20    MCC_ADDR_HI   = 1,
21    MCC_LENGTH    = 2,
22    MCC_CMD       = 3
[758]23};
24
25enum memc_operations
26{
27    MCC_CMD_NOP   = 0,
28    MCC_CMD_INVAL = 1,
29    MCC_CMD_SYNC  = 2
30};
31
32/**
33 * \brief Invalidate all data cache lines corresponding to a memory buffer
34 *        (identified by an address and a size) in L1 cache and L2 cache.
35 */
36void reset_buf_invalidate (void* const buffer, size_t size, int inval_memc)
37{
38    unsigned int i;
39
[911]40    // iterate on L1 cache lines containing target buffer
[758]41    for (i = 0; i <= size; i += CACHE_LINE_SIZE)
42    {
43        asm volatile(
44            " cache %0, %1"
45            : /* no outputs */
46            : "i" (0x11), "R" (*((char*)buffer + i))
47            : "memory"
48            );
49    }
50
[911]51    if (inval_memc)
52    {
53        // this preloader uses only the cluster 0
54        // It does not use the ADDR_HI bits, and does not take
55        // any lock for exclusive access to MCC
56        iowrite32(&mcc_address[MCC_ADDR_LO], (unsigned int) buffer);
57        iowrite32(&mcc_address[MCC_ADDR_HI], (unsigned int) 0);
58        iowrite32(&mcc_address[MCC_LENGTH] , (unsigned int) size);
59        iowrite32(&mcc_address[MCC_CMD]    , (unsigned int) MCC_CMD_INVAL);
60    }
[758]61}
62
63/*
64 * vim: tabstop=4 : softtabstop=4 : shiftwidth=4 : expandtab
65 */
Note: See TracBrowser for help on using the repository browser.