1 /*
2 * Copyright (C) 2017 C-SKY Microsystems Co., Ltd. All rights reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 /******************************************************************************
18 * @file trap_c.c
19 * @brief source file for the trap process
20 * @version V1.0
21 * @date 12. December 2017
22 ******************************************************************************/
23
24 #include <stdint.h>
25 #include <stdio.h>
26 #include <stdlib.h>
27 #include <csi_config.h>
28 #include "wm_debug.h"
29
trap_c(uint32_t * regs)30 void trap_c(uint32_t *regs)
31 {
32 int i;
33 uint32_t vec = 0;
34 __asm__ volatile(
35 "mfcr %0, psr \n"
36 "lsri %0, 16 \n"
37 "sextb %0 \n"
38 :"=r"(vec):);
39 printf("CPU Exception : %u", vec);
40 printf("\n");
41
42 for (i = 0; i < 16; i++) {
43 printf("r%d: %08x\t", i, regs[i]);
44
45 if ((i % 5) == 4) {
46 printf("\n");
47 }
48 }
49
50 printf("\n");
51 printf("epsr: %8x\n", regs[16]);
52 printf("epc : %8x\n", regs[17]);
53
54 while (1) {
55 }
56 }
57
58