summaryrefslogtreecommitdiffstats
path: root/mig_test/software/monitor_functions.c
blob: 5eda564141fd5a068255b90502806297d699d6b8 (plain)
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/*
 * $HeadURL: https://svn.fzd.de/repo/concast/FWF_Projects/FWKE/hw_sp605/bsp_zpuahb/software/monitor_functions.c $
 * $Date$
 * $Author$
 * $Revision$
 */

#include <types.h>
#include "monitor.h"
#include "ambainfo.h"          // apb_info, ahb_info
#include "peripherie.h"


volatile uint8_t running_direction = 0;


/*
    exit the monitor program
*/
uint32_t quit_function( void)
{
    monitor_run = FALSE;
    return 0;
}


/*
    do a memory dump
    arguments:
        start address
        length
*/
uint32_t x_function( void)
{
    uint32_t  addr;
    uint32_t  count;
    uint32_t  index;
    uint32_t* ptr;

    addr  = monitor_get_argument_hex(1);
    count = monitor_get_argument_hex(2);

    // set minimum count, if count is not set
    if (count == 0) count = 16;
    
    // we can only read at 32 bit aligned addresses
    ptr = (uint32_t*)(addr & 0xfffffffc);

    if (count != 1)
    {
        for (index = 0; index < count; index++)
        {
            if ( (index % 4) == 0) 
            {
                putstr("\n0x"); puthex(32, (uint32_t)ptr); putstr(" : ");
            }
            putstr("0x"); puthex( 32, *ptr); putchar(' ');
            *ptr++;
        }
    }
    else
    // fast version without address
    {
        putstr("0x"); puthex( 32, *ptr);
    }
    putchar( '\n');
    return 0;
}


/*
    write specific value on memory
    arguments:
        address
        count
        value(0) .. value(n)
*/
uint32_t wmem_function( void)
{
    uint32_t  addr;
    uint8_t   count;
    uint8_t   index;
    uint32_t  value;
    uint32_t* ptr;
    
    addr  = monitor_get_argument_hex(1);
    count = monitor_get_argument_int(2);

    ptr  = (uint32_t*)addr; // automatic word aligned

    index = 3;
    while (count > 0)
    {
        value = monitor_get_argument_hex(index);
        index++;
        count--;
        *ptr = value;
        ptr++;
    }
    return count;
}


/*
    clear screen
*/
uint32_t clear_function( void) 
{
    putchar('\f');
    return 0;
}


////////////////////////////////////////////////////////////
// reset function
uint32_t reset_function( void)
{
    *reset_reg = 0x87654321;
    return 1;
}


////////////////////////////////////////////////////////////
// system info
uint32_t system_info_function( void)
{
    uint8_t   verbose;

    verbose = monitor_get_argument_int(1); 
    ahb_info( verbose);
    return 0;
}


OpenPOWER on IntegriCloud