OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [bootloaders/] [orpmon/] [cmds/] [global.c] - Blame information for rev 304

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 marcus.erl
#include "common.h"
2
#include "support.h"
3
 
4
global_struct global;
5
 
6
int src_addr_cmd (int argc, char *argv[])
7
{
8
  if (argc == 1) {
9
    global.src_addr = strtoul (argv[0], 0, 0);
10
    return 0;
11
  } else return -1;
12
}
13
 
14
int dst_addr_cmd (int argc, char *argv[])
15
{
16
  if (argc == 1) {
17
    global.dst_addr = strtoul (argv[0], 0, 0);
18
    return 0;
19
  } else return -1;
20
}
21
 
22
int length_cmd (int argc, char *argv[])
23
{
24
  if (argc == 1) {
25
    global.length = strtoul (argv[0], 0, 0);
26
    return 0;
27
  } else return -1;
28
}
29
 
30
int ip_cmd (int argc, char *argv[])
31
{
32
  if (argc == 1) {
33
    global.ip = parse_ip (argv[0]);
34
    return 0;
35
  } else return -1;
36
}
37
 
38
int srv_ip_cmd (int argc, char *argv[])
39
{
40
  if (argc == 1) {
41
    global.srv_ip = parse_ip (argv[0]);
42
    return 0;
43
  } else return -1;
44
}
45
 
46
int erase_method_cmd (int argc, char *argv[])
47
{
48
  if (argc == 1) {
49
    int a = strtoul (argv[0], 0, 0);
50
    if (a < 0 || a > 2) return -1;
51
    global.erase_method = a;
52
    return 0;
53
  } else return -1;
54
}
55
 
56
int start_addr_cmd (int argc, char *argv[])
57
{
58
  if (argc == 1) {
59
    global.start_addr = strtoul (argv[0], 0, 0);
60
    return 0;
61
  } else return -1;
62
}
63
 
64
#if HELP_ENABLED
65
int globals_cmd (int argc, char *argv[])
66
{
67
  const char *erase_method_desc[] = {"do not erase", "fully", "as needed"};
68
  if (argc) return -1;
69
  printf ("src_addr = %08lx\n", global.src_addr);
70
  printf ("dst_addr = %08lx\n", global.dst_addr);
71
  printf ("start_addr = %08lx\n", global.start_addr);
72
  printf ("length = %08lx\n", global.length);
73
  printf ("ip = %08lx\n", global.ip);
74
  printf ("srv_ip = %08lx\n", global.srv_ip);
75
  printf ("erase_method = %i (%s)\n", (int)global.erase_method, erase_method_desc[global.erase_method]);
76
  return 0;
77
}
78
#endif /* HELP_ENABLED */
79
 
80
void module_global_init (void)
81
{
82
  register_command ("src_addr", "<value>", "sets global parameter source address", src_addr_cmd);
83
  register_command ("dst_addr", "<value>", "sets global parameter destination address", dst_addr_cmd);
84
  register_command ("start_addr", "<value>", "sets start address", start_addr_cmd);
85
  register_command ("length", "<value>", "sets global parameter length", length_cmd);
86
  register_command ("ip", "<value> <value> <value>", "sets global parameter ip address", ip_cmd);
87
  register_command ("srv_ip", "<value> <value> <value>", "sets global parameter server ip address", srv_ip_cmd);
88
  register_command ("erase_method", "<value> <value> <value>", "sets flash erase method (0 = do not erase, 1 = fully, 2 = as needed)", erase_method_cmd);
89
  if (HELP_ENABLED) register_command ("globals", "", "show globals", globals_cmd);
90
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.