00001 #include <stdio.h>
00002 #include <stdlib.h>
00003 #include <string.h>
00004
00005 #include "hprocess.h"
00006 #include "hplacer.h"
00007 #include "hicap.h"
00008
00009 static char* bitfilespath = NULL;
00010 static char* icap_device = NULL;
00011
00012 static const char* get_bitfilespath_();
00013 static const char* get_icap_device_();
00014
00015
00016
00017 static const char* get_icap_device_()
00018 {
00019 return icap_device;
00020 }
00021
00022
00023 static const char* get_bitfilespath_()
00024 {
00025 return bitfilespath;
00026 }
00027
00028
00029 int hplacer_set_icapdevice(const char* device)
00030 {
00031 icap_device = realloc(icap_device, strlen(device) + 1);
00032 strcpy(icap_device, device);
00033 return 0;
00034 }
00035
00036
00037 int hplacer_set_bitfilespath(const char* path)
00038 {
00039 bitfilespath = realloc(bitfilespath, strlen(path) + 1);
00040 strcpy(bitfilespath, path);
00041 return 0;
00042 }
00043
00044
00045 char* hplacer_create_full_bitfilename(struct hprocess* process)
00046 {
00047 if (process == NULL)
00048 return NULL;
00049
00050
00051 char* full_filename = calloc(1, strlen(get_bitfilespath_()) + strlen(hprocess_get_bitfilename(process)) + 2);
00052 strcpy(full_filename, get_bitfilespath_());
00053 strcat(full_filename, "/");
00054 strcat(full_filename, hprocess_get_bitfilename(process));
00055
00056 return full_filename;
00057 }
00058
00059
00060 int hplacer_interrupt_process(struct hprocess* process)
00061 {
00062 return 0;
00063 }
00064
00065
00066 int hplacer_load_process(struct hprocess* process)
00067 {
00068 char* filename_full = hplacer_create_full_bitfilename(process);
00069 int device_handle = hicap_open((char*)get_icap_device_(), "XC4VFX12");
00070 if (device_handle < 0)
00071 return -1;
00072
00073 hicap_close(device_handle);
00074 free(filename_full);
00075 return 0;
00076 }
00077
00078