summaryrefslogtreecommitdiffstats
path: root/bsps/powerpc/shared/exceptions/ppc-code-copy.c
blob: b324c4950377ea1849412a6279b1a0a9abc2f065 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/**
 * @file
 *
 * @ingroup RTEMSBSPsPowerPCShared
 *
 * @brief Code copy implementation.
 */

/*
 * Copyright (c) 2009 embedded brains GmbH.  All rights reserved.
 *
 * The license and distribution terms for this file may be
 * found in the file LICENSE in this distribution or at
 * http://www.rtems.org/license/LICENSE.
 */

#include <string.h>

#include <rtems.h>

#include <libcpu/powerpc-utility.h>

void ppc_code_copy(void *dest, const void *src, size_t n)
{
  if (memcmp(dest, src, n) != 0) {
    memcpy(dest, src, n);

    rtems_cache_flush_multiple_data_lines(dest, n);
    ppc_synchronize_data();

    rtems_cache_invalidate_multiple_instruction_lines(dest, n);
    ppc_synchronize_instructions();
  }
}