v3_receive \
v3_pci \
v3_guest_mem_access \
- v3_guest_mem_track
+ v3_guest_mem_track \
+ v3_dvfs
#
#
# Libraries that we need to build
#
-LIBS = libv3_user_host_dev.a libv3_user_keyed_stream.a libv3_ctrl.a libv3_guest_mem.a libv3_fb.a
+LIBS = libv3_user_host_dev.a libv3_user_keyed_stream.a libv3_ctrl.a libv3_guest_mem.a libv3_fb.a libv3_user_dvfs.a
BUILD_EXECS = $(BASE_EXECS) $(EXAMPLE_EXECS) $(EXPERIMENTAL_EXECS)
BUILD_LIBS = $(LIBS)
v3_guest_mem_track : v3_guest_mem_track.c libv3_guest_mem.a libv3_ctrl.a
$(CC) $(CFLAGS) $< -L. -lv3_guest_mem -lv3_ctrl -o $@
+#
+# User DVFS control includse a library and a caller
+#
+libv3_user_dvfs.a : v3_user_dvfs.c v3_user_dvfs.h v3_ctrl.h
+ $(CC) $(CFLAGS) -I../linux_module -c v3_user_dvfs.c
+ $(AR) ruv libv3_user_dvfs.a v3_user_dvfs.o
+ rm -f v3_user_dvfs.o
+
+v3_dvfs : v3_dvfs.c libv3_user_dvfs.a libv3_ctrl.a
+ $(CC) $(CFLAGS) $< -I../linux_module -L. -lv3_user_dvfs -lv3_ctrl -o $@
+
#
# FB (Graphics Console) user interface library (needed for VNC access
--- /dev/null
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "v3_user_dvfs.h"
+
+void usage()
+{
+ fprintf(stderr,"usage: v3_dvfs core|core..core command\n");
+ fprintf(stderr," where command is one of the following\n");
+ fprintf(stderr," acquire direct|external\n");
+ fprintf(stderr," pstate number\n");
+ fprintf(stderr," freq number (kHz)\n");
+ fprintf(stderr," release\n\n");
+ fprintf(stderr,"Look at /proc/v3vee/v3-dvfs to see state\n\n");
+}
+
+
+
+int main(int argc, char *argv[])
+{
+ if (argc!=4 && argc!=3) {
+ usage();
+ return -1;
+ }
+
+
+ uint32_t corestart, coreend, core ;
+ int rc;
+ char *cmd=argv[2];
+
+ if (strstr(argv[1],"..")) {
+ if (sscanf(argv[1],"%u..%u",&corestart,&coreend)!=2) {
+ usage();
+ return -1;
+ }
+ } else {
+ corestart=coreend=atoi(argv[1]);
+ }
+
+
+ if (argc==3 && strcasecmp(cmd,"release")) {
+ usage();
+ return -1;
+ }
+
+ char *arg=argv[3];
+
+ rc=0;
+
+ for (core=corestart;core<=coreend;core++) {
+ if (!strcasecmp(cmd,"acquire")) {
+ if (!strcasecmp(arg,"direct")) {
+ if (v3_user_dvfs_acquire_direct(core)) {
+ fprintf(stderr,"Failed to set core %u to direct\n",core);
+ rc=-1;
+ } else {
+ fprintf(stderr,"Core %u set to direct\n",core);
+ }
+ } else if (!strcasecmp(arg,"external")) {
+ if (v3_user_dvfs_acquire_external(core)) {
+ fprintf(stderr,"Failed to set core %u to external\n",core);
+ rc=-1;
+ } else {
+ fprintf(stderr,"Core %u set to external\n",core);
+ }
+ } else {
+ usage();
+ return -1;
+ }
+ } else if (!strcasecmp(cmd,"pstate")) {
+ if (v3_user_dvfs_set_pstate(core,atoi(arg))) {
+ fprintf(stderr,"Failed to set core %u to pstate %d\n",core,atoi(arg));
+ rc=-1;
+ } else {
+ fprintf(stderr,"Core %u set to pstate %d\n",core,atoi(arg));
+ }
+ } else if (!strcasecmp(cmd,"freq")) {
+ if (v3_user_dvfs_set_freq(core,atoll(arg))) {
+ fprintf(stderr,"Failed to set core %u to frequency %lld kHz\n",core,atoll(arg));
+ rc=-1;
+ } else {
+ fprintf(stderr,"Core %u set to frequency %lld kHz\n",core,atoll(arg));
+ }
+ } else if (!strcasecmp(cmd,"release")) {
+ if (v3_user_dvfs_release(core)) {
+ fprintf(stderr,"Failed to release core %u to host control\n",core);
+ rc=-1;
+ } else {
+ fprintf(stderr,"Released core %u to host control\n",core);
+ }
+ } else {
+ usage();
+ return -1;
+ }
+ }
+
+ return rc;
+
+}
+