cmd_init.c 1 KB
Newer Older
1 2 3 4 5 6 7 8
/*
 * This work is part of the White Rabbit project
 *
 * Copyright (C) 2012 CERN (www.cern.ch)
 * Author: Grzegorz Daniluk <grzegorz.daniluk@cern.ch>
 *
 * Released according to the GNU GPL, version 2 or any later version.
 */
9

10 11
#include <string.h>
#include <wrc.h>
12
#include "shell.h"
13
#include "storage.h"
14
#include "syscon.h"
15
#include "i2c.h"
16

17
static int cmd_init(const char *args[])
18
{
19
	if (!mi2c_devprobe(WRPC_FMC_I2C, FMC_EEPROM_ADR)) {
20
		pp_printf("EEPROM not found..\n");
21 22
		return -1;
	}
23

24
	if (args[0] && !strcasecmp(args[0], "erase")) {
25
		if (storage_init_erase() < 0)
26
			pp_printf("Could not erase init script\n");
27
	} else if (args[1] && !strcasecmp(args[0], "add")) {
28
		if (storage_init_add(args) < 0)
29
			pp_printf("Could not add the command\n");
30
		else
31
			pp_printf("OK.\n");
32
	} else if (args[0] && !strcasecmp(args[0], "show")) {
33
		storage_init_show();
34 35 36
	} else if (args[0] && !strcasecmp(args[0], "boot")) {
		shell_boot_script();
	}
37

38
	return 0;
39
}
40 41 42 43 44

DEFINE_WRC_COMMAND(init) = {
	.name = "init",
	.exec = cmd_init,
};