Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: m-labs/flickernoise
base: c064b09
...
head fork: m-labs/flickernoise
compare: 73bc649
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 1 file changed
  • 0 commit comments
  • 1 contributor
Showing with 89 additions and 4 deletions.
  1. +89 −4 src/shellext.c
View
93 src/shellext.c
@@ -23,14 +23,22 @@
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
+#include <sys/ioctl.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
+#include <string.h>
+#include <bsp/milkymist_pfpu.h>
+#include <bsp/milkymist_tmu.h>
#include "shellext.h"
#include "fbgrab.h"
+#ifndef PFPU_SPREG_COUNT
+#define PFPU_SPREG_COUNT 2
+#endif
+
static int main_viwrite(int argc, char **argv)
{
unsigned int reg, val;
@@ -149,7 +157,75 @@ static int main_fbgrab(int argc, char **argv)
return ret;
}
-rtems_shell_cmd_t shellext_viwrite = {
+static int main_pfpu(int argc, char **argv)
+{
+ static unsigned int dummy[2]
+ __attribute__((aligned(sizeof(struct tmu_vertex))));
+ union {
+ float f;
+ unsigned i;
+ } u;
+ unsigned int program[PFPU_PROGSIZE];
+ float regs[PFPU_REG_COUNT];
+ struct pfpu_td td = {
+ .output = dummy,
+ .hmeshlast = 0,
+ .vmeshlast = 0,
+ .program = program,
+ .progsize = 0,
+ .registers = regs,
+ .update = true,
+ .invalidate = false
+ };
+ char **arg;
+ float *r = regs+PFPU_SPREG_COUNT, *rr;
+ int hex = 0;
+ int fd, res;
+
+ for(arg = argv+1; arg != argv+argc; arg++) {
+ if(strchr(*arg, '.')) {
+ *r++ = atof(*arg);
+ } else if(!strncmp(*arg, "0x", 2)) {
+ u.i = strtoul(*arg, NULL, 0);
+ *r++ = u.f;
+ hex = 1;
+ } else if(strlen(*arg) == 8) {
+ program[td.progsize++] = strtoul(*arg, NULL, 16);
+ } else {
+ fprintf(stderr, "don't understand \"%s\"\n", *arg);
+ return 1;
+ }
+ }
+
+ fd = open("/dev/pfpu", O_RDWR);
+ if(fd < 0) {
+ perror("/dev/pfpu");
+ return 2;
+ }
+ res = ioctl(fd, PFPU_EXECUTE, &td);
+ close(fd);
+
+ if(res < 0) {
+ perror("ioctl(PFPU_EXECUTE)");
+ return 2;
+ }
+
+ for(rr = regs+PFPU_SPREG_COUNT; r != rr; rr++) {
+ if(rr != regs+PFPU_SPREG_COUNT)
+ putchar(' ');
+ if(hex) {
+ u.f = *rr;
+ printf("0x%08x", u.i);
+ } else {
+ printf("%g", *rr);
+ }
+ }
+ putchar('\n');
+
+ return 0;
+}
+
+static rtems_shell_cmd_t shellext_viwrite = {
"viwrite", /* name */
"viwrite register value", /* usage */
"flickernoise", /* topic */
@@ -158,7 +234,7 @@ rtems_shell_cmd_t shellext_viwrite = {
NULL /* next */
};
-rtems_shell_cmd_t shellext_viread = {
+static rtems_shell_cmd_t shellext_viread = {
"viread", /* name */
"viread register", /* usage */
"flickernoise", /* topic */
@@ -167,7 +243,7 @@ rtems_shell_cmd_t shellext_viread = {
&shellext_viwrite /* next */
};
-rtems_shell_cmd_t shellext_erase = {
+static rtems_shell_cmd_t shellext_erase = {
"erase", /* name */
"erase device", /* usage */
"flickernoise", /* topic */
@@ -176,7 +252,7 @@ rtems_shell_cmd_t shellext_erase = {
&shellext_viread /* next */
};
-rtems_shell_cmd_t shellext = {
+static rtems_shell_cmd_t shellext_fbgrab = {
"fbgrab", /* name */
"fbgrab file.png", /* usage */
"flickernoise", /* topic */
@@ -184,3 +260,12 @@ rtems_shell_cmd_t shellext = {
NULL, /* alias */
&shellext_erase /* next */
};
+
+rtems_shell_cmd_t shellext = {
+ "pfpu", /* name */
+ "pfpu reg ... code ...", /* usage */
+ "flickernoise", /* topic */
+ main_pfpu, /* command */
+ NULL, /* alias */
+ &shellext_fbgrab /* next */
+};

No commit comments for this range

Something went wrong with that request. Please try again.