[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r7894 - in gnuradio/branches/developers/eb/gcell-wip/s
From: |
eb |
Subject: |
[Commit-gnuradio] r7894 - in gnuradio/branches/developers/eb/gcell-wip/src: include lib |
Date: |
Thu, 28 Feb 2008 23:50:54 -0700 (MST) |
Author: eb
Date: 2008-02-28 23:50:52 -0700 (Thu, 28 Feb 2008)
New Revision: 7894
Added:
gnuradio/branches/developers/eb/gcell-wip/src/lib/gc_proc_def_utils.cc
gnuradio/branches/developers/eb/gcell-wip/src/lib/gc_proc_def_utils.h
Modified:
gnuradio/branches/developers/eb/gcell-wip/src/include/gc_declare_proc.h
gnuradio/branches/developers/eb/gcell-wip/src/lib/Makefile.am
gnuradio/branches/developers/eb/gcell-wip/src/lib/gc_job_manager_impl.cc
gnuradio/branches/developers/eb/gcell-wip/src/lib/gc_job_manager_impl.h
Log:
work-in-progress on supporting user SPU code
Modified:
gnuradio/branches/developers/eb/gcell-wip/src/include/gc_declare_proc.h
===================================================================
--- gnuradio/branches/developers/eb/gcell-wip/src/include/gc_declare_proc.h
2008-02-29 06:43:45 UTC (rev 7893)
+++ gnuradio/branches/developers/eb/gcell-wip/src/include/gc_declare_proc.h
2008-02-29 06:50:52 UTC (rev 7894)
@@ -24,8 +24,15 @@
#include <stdint.h>
#include <gc_job_desc.h>
-#define GC_PROC_DEF_SECTION_NAME ".gcell.proc_def"
+/*
+ * This is C, not C++ code...
+ *
+ * ...and is used by both PPE and SPE code
+ */
+__GC_BEGIN_DECLS
+#define GC_PROC_DEF_SECTION ".gcell.proc_def"
+
struct gc_proc_def {
#if defined(__SPU__)
gc_spu_proc_t proc;
@@ -48,8 +55,10 @@
*/
#define GC_DECLARE_PROC(_proc_, _name_) \
static struct gc_proc_def \
- _GCPD_ ## _proc_ __attribute__((section(GC_PROC_DEF_SECTION_NAME), used)) = \
+ _GCPD_ ## _proc_ __attribute__((section(GC_PROC_DEF_SECTION), used)) = \
{ _proc_, _name_ }
#endif
+__GC_END_DECLS
+
#endif /* INCLUDED_GC_DECLARE_PROC_H */
Modified: gnuradio/branches/developers/eb/gcell-wip/src/lib/Makefile.am
===================================================================
--- gnuradio/branches/developers/eb/gcell-wip/src/lib/Makefile.am
2008-02-29 06:43:45 UTC (rev 7893)
+++ gnuradio/branches/developers/eb/gcell-wip/src/lib/Makefile.am
2008-02-29 06:50:52 UTC (rev 7894)
@@ -1,5 +1,5 @@
#
-# Copyright 2007 Free Software Foundation, Inc.
+# Copyright 2007,2008 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -31,7 +31,8 @@
gc_job_manager.cc \
gc_job_manager_impl.cc \
gc_jd_queue.c \
- gc_jd_stack.c
+ gc_jd_stack.c \
+ gc_proc_def_utils.cc
libgcell_la_LIBADD = \
-lspe2 \
Modified:
gnuradio/branches/developers/eb/gcell-wip/src/lib/gc_job_manager_impl.cc
===================================================================
--- gnuradio/branches/developers/eb/gcell-wip/src/lib/gc_job_manager_impl.cc
2008-02-29 06:43:45 UTC (rev 7893)
+++ gnuradio/branches/developers/eb/gcell-wip/src/lib/gc_job_manager_impl.cc
2008-02-29 06:50:52 UTC (rev 7894)
@@ -22,8 +22,9 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include "gc_job_manager_impl.h"
-#include "gc_mbox.h"
+#include <gc_job_manager_impl.h>
+#include <gc_mbox.h>
+#include <gc_proc_def_utils.h>
#include <stdio.h>
#include <stdexcept>
@@ -114,7 +115,8 @@
: d_debug(0), d_spu_args(0),
d_eh_cond(&d_eh_mutex), d_eh_thread(0), d_eh_state(EHS_INIT),
d_shutdown_requested(false),
- d_client_thread(0), d_ea_args_maxsize(0)
+ d_client_thread(0), d_ea_args_maxsize(0),
+ d_proc_defs(0), d_nproc_defs(0)
{
if (!s_key_initialized){
int r = pthread_key_create(&s_client_key, client_key_destructor);
@@ -227,6 +229,13 @@
}
d_spe_image = spe_program_handle_sptr(spe_image,
spe_program_handle_deleter());
+ // fish proc_def table out of SPE ELF file
+
+ if (!gcpd_find_table(d_spe_image.get(), &d_proc_defs, &d_nproc_defs)){
+ fprintf(stderr, "gc_job_manager_impl: couldn't find gc_proc_defs in SPE
ELF file.\n");
+ throw std::runtime_error("no gc_proc_defs");
+ }
+
int spe_flags = (SPE_EVENTS_ENABLE
| SPE_CFG_SIGNOTIFY1_OR
| SPE_CFG_SIGNOTIFY2_OR);
@@ -1147,32 +1156,14 @@
////////////////////////////////////////////////////////////////////////
//
-// FIXME fake implementation of proc lookups for now
+// lookup proc names in d_proc_defs table
-#include <gc_proc_ids_private.h>
-
-struct name_map {
- char *proc_name;
- gc_proc_id_t proc_id;
-};
-
-static struct name_map name_map[] = {
- { "qa_nop", GCP_QA_NOP },
- { "qa_udelay", GCP_QA_UDELAY },
- { "qa_sum_shorts", GCP_QA_SUM_SHORTS },
- { "qa_put_seq", GCP_QA_PUT_SEQ },
- { "qa_put_zeros", GCP_QA_PUT_ZEROS },
- { "qa_copy", GCP_QA_COPY }
-};
-
-static const size_t nname_map_entries = sizeof(name_map) / sizeof(name_map[0]);
-
gc_proc_id_t
gc_job_manager_impl::lookup_proc(const std::string &proc_name)
{
- for (size_t i = 0; i < nname_map_entries; i++)
- if (proc_name == name_map[i].proc_name)
- return name_map[i].proc_id;
+ for (size_t i = 0; i < d_nproc_defs; i++)
+ if (proc_name == d_proc_defs[i].name)
+ return i;
return GCP_UNKNOWN_PROC;
}
@@ -1181,8 +1172,8 @@
gc_job_manager_impl::proc_names()
{
std::vector<std::string> r;
- for (size_t i = 0; i < nname_map_entries; i++)
- r.push_back(name_map[i].proc_name);
+ for (size_t i = 0; i < d_nproc_defs; i++)
+ r.push_back(d_proc_defs[i].name);
return r;
}
Modified:
gnuradio/branches/developers/eb/gcell-wip/src/lib/gc_job_manager_impl.h
===================================================================
--- gnuradio/branches/developers/eb/gcell-wip/src/lib/gc_job_manager_impl.h
2008-02-29 06:43:45 UTC (rev 7893)
+++ gnuradio/branches/developers/eb/gcell-wip/src/lib/gc_job_manager_impl.h
2008-02-29 06:50:52 UTC (rev 7894)
@@ -135,6 +135,8 @@
int d_ea_args_maxsize;
+ struct gc_proc_def *d_proc_defs; // the SPE procedure table
+ int d_nproc_defs; // number of proc_defs in table
gc_client_thread_info *alloc_cti();
void free_cti(gc_client_thread_info *cti);
Added: gnuradio/branches/developers/eb/gcell-wip/src/lib/gc_proc_def_utils.cc
===================================================================
--- gnuradio/branches/developers/eb/gcell-wip/src/lib/gc_proc_def_utils.cc
(rev 0)
+++ gnuradio/branches/developers/eb/gcell-wip/src/lib/gc_proc_def_utils.cc
2008-02-29 06:50:52 UTC (rev 7894)
@@ -0,0 +1,121 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <gc_proc_def_utils.h>
+#include <gc_declare_proc.h>
+#include <elf.h>
+#include <stdio.h>
+#include <string.h>
+
+static const unsigned char expected[EI_PAD] = {
+ ELFMAG0,
+ ELFMAG1,
+ ELFMAG2,
+ ELFMAG3,
+ ELFCLASS32,
+ ELFDATA2MSB,
+ EV_CURRENT,
+ ELFOSABI_SYSV,
+ 0
+};
+
+
+/*
+ * Basically we're going to find the GC_PROC_DEF_SECTION section
+ * in the ELF file and return a pointer to it. The only things in that
+ * section are gc_proc_def's
+ */
+bool
+gcpd_find_table(spe_program_handle_t *handle, struct gc_proc_def **table, int
*nentries)
+{
+ if (!handle || !table || !nentries)
+ return false;
+
+ *table = 0;
+ *nentries = 0;
+
+ Elf32_Ehdr *ehdr = (Elf32_Ehdr *)handle->elf_image;
+ if (!ehdr){
+ fprintf(stderr, "gcpd: No ELF image has been loaded\n");
+ return false;
+ }
+
+ // quick check that we're looking at a SPE EXEC object
+
+ if (memcmp(ehdr->e_ident, expected, EI_PAD) != 0){
+ fprintf(stderr, "gcpd: invalid ELF header\n");
+ return false;
+ }
+
+ if (ehdr->e_machine != 0x17){ // confirm machine type (EM_SPU)
+ fprintf(stderr, "gcpd: not an SPE ELF object\n");
+ return false;
+ }
+
+ if (ehdr->e_type != ET_EXEC){
+ fprintf(stderr, "gcpd: invalid SPE ELF type.\n");
+ fprintf(stderr, "gcpd: SPE type %d != %d\n", ehdr->e_type, ET_EXEC);
+ return false;
+ }
+
+ // find the section header table
+
+ Elf32_Shdr *shdr;
+ Elf32_Shdr *sh;
+
+ if (ehdr->e_shentsize != sizeof (*shdr)){
+ fprintf(stderr, "gcpd: invalid section header format.\n");
+ return false;
+ }
+
+ if (ehdr->e_shnum == 0){
+ fprintf(stderr, "gcpd: no section headers in file.\n");
+ return false;
+ }
+
+ shdr = (Elf32_Shdr *) ((char *)ehdr + ehdr->e_shoff);
+ char *str_table = (char *)ehdr + shdr[ehdr->e_shstrndx].sh_offset;
+
+ // traverse the sections looking for GC_PROC_DEF_SECTION
+
+ for (sh = shdr; sh < &shdr[ehdr->e_shnum]; sh++){
+ if (0){
+ fprintf(stderr, "section name: %s ( start: 0x%04x, size: 0x%04x)\n",
+ str_table + sh->sh_name, sh->sh_offset, sh->sh_size);
+ }
+
+ if (strcmp(GC_PROC_DEF_SECTION, str_table+sh->sh_name) == 0){
+ *table = (struct gc_proc_def *)((char *)ehdr + sh->sh_offset);
+ if (sh->sh_size % (sizeof(struct gc_proc_def)) != 0){
+ fprintf(stderr, "gcpd: %s section has invalid format\n",
GC_PROC_DEF_SECTION);
+ return false;
+ }
+ *nentries = sh->sh_size / sizeof(struct gc_proc_def);
+ return true;
+ }
+ }
+
+ return false;
+}
Property changes on:
gnuradio/branches/developers/eb/gcell-wip/src/lib/gc_proc_def_utils.cc
___________________________________________________________________
Name: svn:eol-style
+ native
Added: gnuradio/branches/developers/eb/gcell-wip/src/lib/gc_proc_def_utils.h
===================================================================
--- gnuradio/branches/developers/eb/gcell-wip/src/lib/gc_proc_def_utils.h
(rev 0)
+++ gnuradio/branches/developers/eb/gcell-wip/src/lib/gc_proc_def_utils.h
2008-02-29 06:50:52 UTC (rev 7894)
@@ -0,0 +1,40 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+#ifndef INCLUDED_GC_PROC_DEF_UTILS_H
+#define INCLUDED_GC_PROC_DEF_UTILS_H
+
+#include <gc_declare_proc.h>
+#include <libspe2.h>
+
+/*!
+ * \brief find the gc_proc_def table in the SPE program
+ *
+ * \param[in] program is the handle to the loaded SPE program
+ * \param[out] table points to the table, if it's found
+ * \param[out] nentries is set to the number of entries in the table.
+ *
+ * \returns true if successful, else false
+ */
+bool
+gcpd_find_table(spe_program_handle_t *program, struct gc_proc_def **table, int
*nentries);
+
+
+#endif /* INCLUDED_GC_PROC_DEF_UTILS_H */
Property changes on:
gnuradio/branches/developers/eb/gcell-wip/src/lib/gc_proc_def_utils.h
___________________________________________________________________
Name: svn:eol-style
+ native
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r7894 - in gnuradio/branches/developers/eb/gcell-wip/src: include lib,
eb <=