/* * hwman.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" /* common objects */ #include "pkt.h" #include "set.h" #include "daemon.h" /* include command declarations */ #include "swload_cmds.h" #include "hwman_cmds.h" /* main function declaration */ void hwman_run(); void hwman_alloc(); int hwman_init(daemon_o daemon); void hwman_background(); #ifdef RUN_AS_PROC int main() { hwman_run(); return 1; } #endif cmd_t cmds[] = { { HWMAN_LISTCPU, hwman_incmd_listcpu, "List processors", "Error listing processors" }, { HWMAN_MAPOBJ, hwman_incmd_swmapper, "Map (allocate) software", "Error mapping software" }, { HWMAN_UNMAPOBJ, hwman_incmd_swunmap, "Unmap (deallocate) software", "Error unmapping software" }, { HWMAN_ADDITF, hwman_incmd_additf, "Add interface", "Error adding interface" }, { HWMAN_UPDCPU, hwman_incmd_updcpu, "Update processor", "Error updating processor" }, { HWMAN_ADDCPU, hwman_incmd_addcpu, "Add processor", "Error adding processor" }, { 0, NULL, NULL, NULL}}; void hwman_run() { daemon_o daemon; int n; if (!hwapi_init()) { xprintf("Error initiating HWAPI. Exiting...\n"); exit(-1); } hwman_alloc(); daemon = daemon_new(DAEMON_HWMAN, cmds); if (!daemon) { xprintf("HWMAN: Error creating daemon\n"); exit(-1); } if (!hwman_init(daemon)) { xprintf("HWMAN: Error initiating daemon\n"); exit(-1); } xprintf("HWMAN: Init ok\n"); /** main daemon loop * while packets in queue, process them */ while (1) { do { n = daemon_rcvpkt(daemon); if (n > 0) { daemon_processcmd(daemon); } if (n<0) { exit(-1); } } while (n > 0); hwman_background(); hwapi_relinquish_daemon(); } daemon_delete(&daemon); exit(-1); }