00001
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #include <l4/thread/thread.h>
00037 #include <autoconfig.h>
00038 #include "oq_ore.h"
00039 #include <oq.h>
00040 #include <orbisquartus.h>
00041 #include <mini_mpi.h>
00042 #include <daemon.h>
00043 #include "ituner_lcd.h"
00044
00045
00046 void OrbisQuartus::_init()
00047 {
00048 ore_args_t args;
00049
00050
00051 ituner_lcd_init();
00052 ituner_lcd_print(1, " %, version %s", PACKAGE_NAME, PACKAGE_VERSION);
00053 ituner_lcd_print(2, " Copyright %d.", COPYRIGHT_YEAR);
00054
00055 args.debug = 0;
00056 args.events = 0;
00057 args.loopback_only = 0;
00058 strncpy(args.mac_address, "", MAC_ADDR_SIZE - 1);
00059
00060 printf("initializing OQ ore routing\n");
00061 l4thread_create(oq_ore_routing, NULL, L4THREAD_CREATE_ASYNC);
00062
00063 }
00064
00065
00066 int OrbisQuartus::_get_config(int argc, char *argv[])
00067 {
00068 int ctl_sock, flag = 0;
00069
00070
00071
00072
00073
00074 MPI_Initialized(&flag);
00075 if (flag == 0) {
00076 MPI_Init(&argc, &argv);
00077 MPI_Comm_size(MPI_COMM_WORLD, &numprocs);
00078 MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
00079 }
00080 MPI_Comm_socket(MPI_COMM_WORLD, &ctl_sock);
00081 #if 0
00082
00083 if ((numbytes = recv(ctl_sock, len_str, INTEGER_STRING, 0)) < 0)
00084 return numbytes;
00085 num_mynodes = atoi(len_str);
00086 assign_len = (2 * num_mynodes) - 1;
00087
00088 assignmt = (char*) malloc(sizeof(char) * (assign_len + 1));
00089 if ((numbytes = recv(ctl_sock, assignmt, assign_len, 0)) < 0)
00090 return numbytes;
00091
00092 mynodes = (unsigned long*) malloc(sizeof(unsigned long) * num_mynodes);
00093 assgn = assignmt;
00094 for (i = 0; i < num_mynodes &&
00095 (sptr = index(assgn, ',')) != NULL; i++) {
00096 sptr = '\0';
00097 sscanf(assgn, "%lu", &mynodes[i]);
00098 assgn = sptr + 1;
00099 }
00100 sscanf(assgn, "%lu", &mynodes[i]);
00101 free(assignmt);
00102
00103
00104 if ((numbytes = recv(ctl_sock, len_str, INTEGER_STRING, 0)) < 0)
00105 return numbytes;
00106 cfg_len = atoi(len_str);
00107
00108 numbytes = 0;
00109 config = (char*) malloc(sizeof(char) * (cfg_len + 1));
00110 while (numbytes < cfg_len) {
00111 recvd_bytes = recv(ctl_sock, config, cfg_len, 0);
00112 numbytes += recvd_bytes;
00113 }
00114 cfg.xml_to_cfg(config);
00115 free(config);
00116 #endif
00117 return 0;
00118 }
00119
00120
00121 void OrbisQuartus::stop(void)
00122 {
00123 daemon_quit();
00124 l4thread_shutdown(sim_thread);
00125 l4thread_shutdown(vt_thread);
00126 l4thread_shutdown(ctl_thread);
00127 MPI_Finalize();
00128 }