Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: m-labs/flickernoise
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: c064b09
Choose a base ref
...
head repository: m-labs/flickernoise
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 73bc649
Choose a head ref
  • 2 commits
  • 1 file changed
  • 1 contributor

Commits on Jan 15, 2012

  1. Copy the full SHA
    db844fc View commit details
  2. shellext: new command "pfpu" to execute a short PFPU program

    This is for PFPU debugging. Use at your own peril.
    wpwrak committed Jan 15, 2012
    Copy the full SHA
    73bc649 View commit details
Showing with 89 additions and 4 deletions.
  1. +89 −4 src/shellext.c
93 changes: 89 additions & 4 deletions src/shellext.c
Original file line number Diff line number Diff line change
@@ -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,11 +252,20 @@ 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 */
main_fbgrab, /* command */
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 */
};