/* * swload.c * * Copyright (c) 2009 Ismael Gomez-Miguelez, UPC . All rights reserved. * * * This file is part of ALOE. * * ALOE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * ALOE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with ALOE. If not, see . * */ /* standard libraries */ #include #include #include "phal_hw_api.h" #include "phid.h" #include "phal_daemons.h" #include "pkt.h" #include "set.h" #include "daemon.h" #include "swload_cmds.h" /* main function declaration */ void swload_run(); void swload_alloc(); int swload_init(daemon_o dameon); #ifdef RUN_AS_PROC int main() { swload_run(); return 1; } #endif int swload_init(daemon_o d); static cmd_t cmds[] = {{ SWLOAD_LOADOBJ, swload_incmd_loadobj, "Load a list of objects", "Error loading objects"}, { SWLOAD_EXECERR, swload_incmd_execerr, "Error loading object", "Error loading object"}, { SWLOAD_EXECINFO, swload_incmd_execinfo, "Allocate object", "Error allocating object"}, { SWLOAD_LOADSTART, swload_incmd_loadstart, "Start object download", "Error loading object"}, { SWLOAD_LOADING, swload_incmd_loading, "Download object", "Error loading object"}, { SWLOAD_LOADEND, swload_incmd_loadend, "Launch object", "Error launching object"}, { 0, NULL, NULL, NULL}}; /** STATS MANAGER DAEMON MAIN FUNCTION * */ void swload_run() { daemon_o daemon; int n; if (!hwapi_init ()) { printf("Error initiating api\n"); exit(-1); } swload_alloc(); daemon = daemon_new(DAEMON_SWLOAD, cmds); if (!daemon) { xprintf ("stats: Error creating daemon\n"); exit(-1); } if (swload_init(daemon) < 0) { exit(-1); } xprintf ("SWLOAD: Init Ok\n"); /** main daemon loop */ while (1) { do { n = daemon_rcvpkt(daemon); if (n>0) { daemon_processcmd(daemon); } if (n<0) { exit(-1); } } while (n>0); hwapi_relinquish_daemon(); } daemon_delete(&daemon); exit(-1); }