summaryrefslogtreecommitdiff
path: root/gcell/src/include
diff options
context:
space:
mode:
Diffstat (limited to 'gcell/src/include')
-rw-r--r--gcell/src/include/Makefile.am39
-rw-r--r--gcell/src/include/compiler.h43
-rw-r--r--gcell/src/include/gc_atomic.h29
-rw-r--r--gcell/src/include/gc_cdefs.h34
-rw-r--r--gcell/src/include/gc_declare_proc.h64
-rw-r--r--gcell/src/include/gc_jd_queue.h52
-rw-r--r--gcell/src/include/gc_jd_queue_data.h51
-rw-r--r--gcell/src/include/gc_jd_stack.h70
-rw-r--r--gcell/src/include/gc_job_desc.h213
-rw-r--r--gcell/src/include/gc_job_desc_private.h39
-rw-r--r--gcell/src/include/gc_logging.h166
-rw-r--r--gcell/src/include/gc_mbox.h52
-rw-r--r--gcell/src/include/gc_spu_args.h60
-rw-r--r--gcell/src/include/gc_types.h63
-rw-r--r--gcell/src/include/memory_barrier.h66
-rw-r--r--gcell/src/include/spu/Makefile.am25
-rw-r--r--gcell/src/include/spu/gc_delay.h27
-rw-r--r--gcell/src/include/spu/gc_jd_queue.h57
18 files changed, 1150 insertions, 0 deletions
diff --git a/gcell/src/include/Makefile.am b/gcell/src/include/Makefile.am
new file mode 100644
index 000000000..1e65282d7
--- /dev/null
+++ b/gcell/src/include/Makefile.am
@@ -0,0 +1,39 @@
+#
+# Copyright 2007,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.
+#
+
+include $(top_srcdir)/Makefile.common
+
+SUBDIRS = spu
+
+gcellinclude_HEADERS = \
+ compiler.h \
+ gc_atomic.h \
+ gc_cdefs.h \
+ gc_declare_proc.h \
+ gc_jd_queue_data.h \
+ gc_jd_queue.h \
+ gc_jd_stack.h \
+ gc_job_desc.h \
+ gc_job_desc_private.h \
+ gc_logging.h \
+ gc_mbox.h \
+ gc_spu_args.h \
+ gc_types.h \
+ memory_barrier.h
diff --git a/gcell/src/include/compiler.h b/gcell/src/include/compiler.h
new file mode 100644
index 000000000..74a9739f8
--- /dev/null
+++ b/gcell/src/include/compiler.h
@@ -0,0 +1,43 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 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_COMPILER_H
+#define INCLUDED_COMPILER_H
+
+/*!
+ * \brief Compiler specific hackery. These are for GCC.
+ */
+
+#define _AL8 __attribute__((aligned (8)))
+#define _AL16 __attribute__((aligned (16)))
+#define _AL128 __attribute__((aligned (128)))
+
+#ifndef likely
+#define likely(x) __builtin_expect(!!(x), 1)
+#define unlikely(x) __builtin_expect(!!(x), 0)
+#endif
+
+#ifndef offsetof
+#define offsetof(TYPE, MEMBER) __builtin_offsetof (TYPE, MEMBER)
+#endif
+
+
+#endif /* INCLUDED_COMPILER_H */
diff --git a/gcell/src/include/gc_atomic.h b/gcell/src/include/gc_atomic.h
new file mode 100644
index 000000000..01737cd03
--- /dev/null
+++ b/gcell/src/include/gc_atomic.h
@@ -0,0 +1,29 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 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_ATOMIC_H
+#define INCLUDED_GC_ATOMIC_H
+
+#include <stdint.h>
+
+typedef uint32_t gc_atomic_t;
+
+
+#endif /* INCLUDED_GC_ATOMIC_H */
diff --git a/gcell/src/include/gc_cdefs.h b/gcell/src/include/gc_cdefs.h
new file mode 100644
index 000000000..93084bae4
--- /dev/null
+++ b/gcell/src/include/gc_cdefs.h
@@ -0,0 +1,34 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 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_CDEFS_H
+#define INCLUDED_GC_CDEFS_H
+
+/* C++ needs to know that types and declarations are C, not C++. */
+#ifdef __cplusplus
+# define __GC_BEGIN_DECLS extern "C" {
+# define __GC_END_DECLS }
+#else
+# define __GC_BEGIN_DECLS
+# define __GC_END_DECLS
+#endif
+
+#endif /* INCLUDED_GC_CDEFS_H */
diff --git a/gcell/src/include/gc_declare_proc.h b/gcell/src/include/gc_declare_proc.h
new file mode 100644
index 000000000..37af5bab7
--- /dev/null
+++ b/gcell/src/include/gc_declare_proc.h
@@ -0,0 +1,64 @@
+/* -*- 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_DECLARE_PROC_H
+#define INCLUDED_GC_DECLARE_PROC_H
+
+#include <stdint.h>
+#include <gc_job_desc.h>
+
+/*
+ * 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"
+
+typedef struct gc_proc_def {
+#if defined(__SPU__)
+ gc_spu_proc_t proc;
+#else
+ uint32_t proc;
+#endif
+ char name[28];
+} _AL16 gc_proc_def_t;
+
+
+#if defined(__SPU__)
+/*!
+ * \brief Tell gcell about a SPU procedure
+ *
+ * \param _proc_ pointer to function (gc_spu_proc_t)
+ * \param _name_ the name of the procedure ("quoted string")
+ *
+ * This macro registers the given procedure with the gcell runtime.
+ * From the PPE, use gc_job_manager::lookup_proc to map \p _name_ to a gc_proc_id_t
+ */
+#define GC_DECLARE_PROC(_proc_, _name_) \
+static struct gc_proc_def \
+ _GCPD_ ## _proc_ __attribute__((section(GC_PROC_DEF_SECTION), used)) = \
+ { _proc_, _name_ }
+#endif
+
+__GC_END_DECLS
+
+#endif /* INCLUDED_GC_DECLARE_PROC_H */
diff --git a/gcell/src/include/gc_jd_queue.h b/gcell/src/include/gc_jd_queue.h
new file mode 100644
index 000000000..f5f8a1a0d
--- /dev/null
+++ b/gcell/src/include/gc_jd_queue.h
@@ -0,0 +1,52 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 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_JD_QUEUE_H
+#define INCLUDED_GC_JD_QUEUE_H
+
+#include "gc_jd_queue_data.h"
+
+__GC_BEGIN_DECLS
+
+/*!
+ * \brief Initialize the queue to empty.
+ */
+void
+gc_jd_queue_init(gc_jd_queue_t *q);
+
+
+/*!
+ * \brief Add \p item to the tail of \p q.
+ */
+void
+gc_jd_queue_enqueue(gc_jd_queue_t *q, gc_job_desc_t *item);
+
+
+/*!
+ * \brief Remove and return item at head of queue, or 0 if queue is empty
+ */
+gc_job_desc_t *
+gc_jd_queue_dequeue(gc_jd_queue_t *q);
+
+__GC_END_DECLS
+
+
+#endif /* INCLUDED_GC_JD_QUEUE_H */
diff --git a/gcell/src/include/gc_jd_queue_data.h b/gcell/src/include/gc_jd_queue_data.h
new file mode 100644
index 000000000..d48591bd2
--- /dev/null
+++ b/gcell/src/include/gc_jd_queue_data.h
@@ -0,0 +1,51 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 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_JD_QUEUE_DATA_H
+#define INCLUDED_GC_JD_QUEUE_DATA_H
+
+#include "gc_types.h"
+#include "gc_job_desc.h"
+
+__GC_BEGIN_DECLS
+
+/*!
+ * \brief (Lock free someday...) queue for job descriptors
+ *
+ * This is the main data structure shared between PPEs and SPEs.
+ * It is used to enqueue work for SPEs. SPEs or PPEs may enqueue
+ * work. SPE's dequeue from here.
+ *
+ * FIXME make it lock free ;) For now, use a spin lock.
+ */
+typedef struct gc_jd_queue
+{
+ gc_eaddr_t head _AL16;
+ gc_eaddr_t tail _AL16;
+ uint32_t mutex; // libsync mutex (spin lock)
+} gc_jd_queue_t;
+
+
+__GC_END_DECLS
+
+#endif /* INCLUDED_GC_JD_QUEUE_DATA_H */
+
+
diff --git a/gcell/src/include/gc_jd_stack.h b/gcell/src/include/gc_jd_stack.h
new file mode 100644
index 000000000..72e9435ce
--- /dev/null
+++ b/gcell/src/include/gc_jd_stack.h
@@ -0,0 +1,70 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 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_JD_STACK_H
+#define INCLUDED_GC_JD_STACK_H
+
+#include "gc_types.h"
+#include "gc_job_desc.h"
+
+__GC_BEGIN_DECLS
+
+/*!
+ * \brief Lock free stack for job descriptors (used for free list)
+ *
+ * This is aligned to a cache line, and fills the cache line,
+ * to avoid inadvertently losing reservations created with
+ * the load-and-reserve instructions.
+ */
+
+typedef struct gc_jd_stack
+{
+ gc_eaddr_t top;
+
+ // pad out to a full cache line
+ uint8_t _pad[128 - sizeof(gc_eaddr_t)];
+} _AL128 gc_jd_stack_t;
+
+
+/*!
+ * \brief Initialize the stack to empty.
+ */
+void
+gc_jd_stack_init(gc_jd_stack_t *stack);
+
+
+/*!
+ * \brief Add \p item to the top of \p stack.
+ */
+void
+gc_jd_stack_push(gc_jd_stack_t *stack, gc_job_desc_t *item);
+
+
+/*!
+ * \brief pop and return top item on stack, or 0 if stack is empty
+ */
+gc_job_desc_t *
+gc_jd_stack_pop(gc_jd_stack_t *stack);
+
+__GC_END_DECLS
+
+
+#endif /* INCLUDED_GC_JD_STACK_H */
diff --git a/gcell/src/include/gc_job_desc.h b/gcell/src/include/gc_job_desc.h
new file mode 100644
index 000000000..b79150678
--- /dev/null
+++ b/gcell/src/include/gc_job_desc.h
@@ -0,0 +1,213 @@
+/* -*- c -*- */
+/*
+ * Copyright 2007,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_JOB_DESC_H
+#define INCLUDED_GC_JOB_DESC_H
+
+/*!
+ * This file contains the structures that are used to describe how to
+ * call "jobs" that execute on the SPEs. A "job" is a task, or piece of
+ * work that you want to run on an SPE.
+ *
+ * There is code running in the SPE that knows how to interpret
+ * these job descriptions. Thus, in most cases, the overhead
+ * of invoking these is very low.
+ *
+ * The whole "job idea" is SPE centric. At first pass,
+ * the PPE will be constructing jobs and enqueing them.
+ * However, there is nothing in the implementation that
+ * prohibits SPEs from creating their own jobs in the
+ * future. Also, there is nothing prohibiting SPE-to-SPE
+ * DMA's.
+ *
+ * SPE's dequeue and "pull" jobs to themselves, do the work, then
+ * notify the entity that submitted the job.
+ */
+
+#include "gc_types.h"
+#include "gc_job_desc_private.h"
+
+/*
+ * This is C, not C++ code...
+ *
+ * ...and is used by both PPE and SPE code
+ */
+__GC_BEGIN_DECLS
+
+
+//! opaque ID that specifies which code to invoke on the SPE
+typedef uint32_t gc_proc_id_t;
+#define GCP_UNKNOWN_PROC ((gc_proc_id_t) -1)
+
+
+//! final job status
+typedef enum {
+ JS_OK,
+ JS_SHUTTING_DOWN, // job mananger is shutting down
+ JS_TOO_MANY_CLIENTS, // too many client threads
+ JS_UNKNOWN_PROC, // didn't recognize the procedure ID
+ JS_BAD_DIRECTION, // EA arg has invalid direction
+ JS_BAD_EAH, // not all EA args have the same high 32 address bits
+ JS_BAD_N_DIRECT, // too many direct args
+ JS_BAD_N_EA, // too many EA args
+ JS_ARGS_TOO_LONG, // total length of EA args exceeds limit
+ JS_BAD_JUJU, // misc problem: you're having a bad day
+ JS_BAD_JOB_DESC, // gc_job_desc was not allocated using mgr->alloc_job_desc()
+
+} gc_job_status_t;
+
+#define MAX_ARGS_DIRECT 8 // maximum number of args passed using "direct" method
+#define MAX_ARGS_EA 8 // maximum number of args passed via EA memory (dma)
+
+/*
+ * We support two classes of arguments,
+ * "direct", which are contained in the gc_job_desc_args and
+ * "EA", which are copied in/out according to info in gc_job_desc_args
+ */
+
+/*!
+ * \brief Tag type of "direct" argument
+ */
+typedef enum {
+ GCT_S32,
+ GCT_U32,
+ GCT_S64,
+ GCT_U64,
+ GCT_FLOAT,
+ GCT_DOUBLE,
+ GCT_FLT_CMPLX,
+ GCT_DBL_CMPLX,
+ GCT_EADDR,
+
+} gc_tag_t;
+
+
+/*!
+ * \brief union for passing "direct" argument
+ */
+typedef union gc_arg_union
+{
+ int32_t s32;
+ uint32_t u32;
+ int64_t s64;
+ uint64_t u64;
+ float f;
+ double d;
+ //float complex cf; // 64-bits (C99)
+ //double complex cd; // 128-bits (C99)
+ gc_eaddr_t ea; // 64-bits
+} _AL8 gc_arg_union_t;
+
+
+/*!
+ * \brief "direct" input or output arguments
+ */
+typedef struct gc_job_direct_args
+{
+ uint32_t nargs; // # of "direct" args
+ gc_tag_t tag[MAX_ARGS_DIRECT] _AL16; // type of direct arg[i]
+ gc_arg_union_t arg[MAX_ARGS_DIRECT] _AL16; // direct argument values
+
+} _AL16 gc_job_direct_args_t;
+
+
+// specifies direction for args passed in EA memory
+
+#define GCJD_DMA_GET 0x01 // in to SPE
+#define GCJD_DMA_PUT 0x02 // out from SPE
+
+/*!
+ * \brief Description of args passed in EA memory.
+ * These are DMA'd between EA and LS as specified.
+ */
+typedef struct gc_job_ea_arg {
+ //! EA address of buffer
+ gc_eaddr_t ea_addr;
+
+ //! GC_JD_DMA_* get arg or put arg
+ uint32_t direction;
+
+ //! number of bytes to get
+ uint32_t get_size;
+
+ //! number of bytes to put
+ uint32_t put_size;
+
+#if defined(__SPU__)
+ //! local store address (filled in by SPU runtime)
+ void *ls_addr;
+ uint32_t _pad[2];
+#else
+ uint32_t _pad[3];
+#endif
+
+} _AL16 gc_job_ea_arg_t;
+
+
+typedef struct gc_job_ea_args {
+ uint32_t nargs;
+ gc_job_ea_arg_t arg[MAX_ARGS_EA];
+
+} _AL16 gc_job_ea_args_t;
+
+
+/*!
+ * \brief "job description" that is DMA'd to/from the SPE.
+ */
+typedef struct gc_job_desc
+{
+ gc_job_desc_private_t sys; // internals
+ gc_job_status_t status; // what happened (output)
+ gc_proc_id_t proc_id; // specifies which procedure to run
+ gc_job_direct_args_t input; // direct args to SPE
+ gc_job_direct_args_t output; // direct args from SPE
+ gc_job_ea_args_t eaa; // args passed via EA memory
+
+} _AL128 gc_job_desc_t;
+
+
+/*!
+ * type of procedure invoked on spu
+ */
+typedef void (*gc_spu_proc_t)(const gc_job_direct_args_t *input,
+ gc_job_direct_args_t *output,
+ const gc_job_ea_args_t *eaa);
+
+#if !defined(__SPU__)
+
+static inline gc_job_desc_t *
+ea_to_jdp(gc_eaddr_t ea)
+{
+ return (gc_job_desc_t *) ea_to_ptr(ea);
+}
+
+static inline gc_eaddr_t
+jdp_to_ea(gc_job_desc_t *item)
+{
+ return ptr_to_ea(item);
+}
+
+#endif
+
+
+__GC_END_DECLS
+
+#endif /* INCLUDED_GC_JOB_DESC_H */
diff --git a/gcell/src/include/gc_job_desc_private.h b/gcell/src/include/gc_job_desc_private.h
new file mode 100644
index 000000000..1f76d862b
--- /dev/null
+++ b/gcell/src/include/gc_job_desc_private.h
@@ -0,0 +1,39 @@
+/* -*- c -*- */
+/*
+ * Copyright 2007 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_JOB_DESC_PRIVATE_H
+#define INCLUDED_GC_JOB_DESC_PRIVATE_H
+
+// #include <libsync.h>
+
+/*!
+ * \brief Implementation details we'd like to hide from the user.
+ */
+typedef struct gc_job_desc_private
+{
+ gc_eaddr_t next; // used to implement job queue and free list
+ uint16_t job_id;
+ uint16_t client_id;
+ uint32_t direction_union; // union of all gc_job_ea_arg.direction fields
+} gc_job_desc_private_t;
+
+#endif /* INCLUDED_GC_JOB_PRIVATE_H */
+
diff --git a/gcell/src/include/gc_logging.h b/gcell/src/include/gc_logging.h
new file mode 100644
index 000000000..b98c283a2
--- /dev/null
+++ b/gcell/src/include/gc_logging.h
@@ -0,0 +1,166 @@
+/* -*- 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_LOGGING_H
+#define INCLUDED_GC_LOGGING_H
+
+#include <gc_types.h>
+#include <string.h>
+
+__GC_BEGIN_DECLS
+
+typedef struct gc_log {
+ gc_eaddr_t base; // gc_log_entry_t * (16 byte aligned)
+ uint32_t nentries; // number of entries (power-of-2)
+} gc_log_t;
+
+typedef struct gc_log_entry {
+ uint32_t seqno; // monotonic sequence number
+ uint32_t timestamp; // decrementer value (wraps every 53s on PS3)
+ uint16_t subsystem; // 0 to 255 reserved for system, user gets 256 and up
+ uint16_t event;
+ uint32_t info[5];
+} _AL16 gc_log_entry_t;
+
+#define GCL_SS_SYS 0 // lowest system reserved subsystem
+#define GCL_SS_USER 256 // lowest user reserved subsystem
+
+
+/*
+ * The resulting log files can be displayed using using:
+ *
+ * $ od -t x4 -w32 spu_log.00 | less
+ */
+
+
+#if defined(__SPU__)
+
+/*!
+ * System fills in seqno and timestamp. User is responsible for the rest.
+ */
+
+void _gc_log_write(gc_log_entry_t entry);
+
+#ifdef ENABLE_GC_LOGGING
+#define gc_log_write(entry) _gc_log_write(entry)
+#else
+#define gc_log_write(entry) do { } while (0)
+#endif
+
+inline static void
+gc_log_write0(int subsystem, int event)
+{
+ gc_log_entry_t e;
+ e.subsystem = subsystem;
+ e.event = event;
+ e.info[0] = 0;
+ e.info[1] = 0;
+ e.info[2] = 0;
+ e.info[3] = 0;
+ e.info[4] = 0;
+ gc_log_write(e);
+}
+
+inline static void
+gc_log_write1(int subsystem, int event,
+ uint32_t info0)
+{
+ gc_log_entry_t e;
+ e.subsystem = subsystem;
+ e.event = event;
+ e.info[0] = info0;
+ e.info[1] = 0;
+ e.info[2] = 0;
+ e.info[3] = 0;
+ e.info[4] = 0;
+ gc_log_write(e);
+}
+
+inline static void
+gc_log_write2(int subsystem, int event,
+ uint32_t info0, uint32_t info1)
+{
+ gc_log_entry_t e;
+ e.subsystem = subsystem;
+ e.event = event;
+ e.info[0] = info0;
+ e.info[1] = info1;
+ e.info[2] = 0;
+ e.info[3] = 0;
+ e.info[4] = 0;
+ gc_log_write(e);
+}
+
+inline static void
+gc_log_write3(int subsystem, int event,
+ uint32_t info0, uint32_t info1, uint32_t info2)
+{
+ gc_log_entry_t e;
+ e.subsystem = subsystem;
+ e.event = event;
+ e.info[0] = info0;
+ e.info[1] = info1;
+ e.info[2] = info2;
+ e.info[3] = 0;
+ e.info[4] = 0;
+ gc_log_write(e);
+}
+
+inline static void
+gc_log_write4(int subsystem, int event,
+ uint32_t info0, uint32_t info1, uint32_t info2, uint32_t info3)
+{
+ gc_log_entry_t e;
+ e.subsystem = subsystem;
+ e.event = event;
+ e.info[0] = info0;
+ e.info[1] = info1;
+ e.info[2] = info2;
+ e.info[3] = info3;
+ e.info[4] = 0;
+ gc_log_write(e);
+}
+
+inline static void
+gc_log_write5(int subsystem, int event,
+ uint32_t info0, uint32_t info1, uint32_t info2, uint32_t info3, uint32_t info4)
+{
+ gc_log_entry_t e;
+ e.subsystem = subsystem;
+ e.event = event;
+ e.info[0] = info0;
+ e.info[1] = info1;
+ e.info[2] = info2;
+ e.info[3] = info3;
+ e.info[4] = info4;
+ gc_log_write(e);
+}
+
+/*!
+ * One time initialization called by system runtime
+ */
+void
+_gc_log_init(gc_log_t log_info);
+
+#endif
+
+__GC_END_DECLS
+
+#endif /* INCLUDED_GC_LOGGING_H */
diff --git a/gcell/src/include/gc_mbox.h b/gcell/src/include/gc_mbox.h
new file mode 100644
index 000000000..32b23c6fa
--- /dev/null
+++ b/gcell/src/include/gc_mbox.h
@@ -0,0 +1,52 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007,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_MBOX_H
+#define INCLUDED_GC_MBOX_H
+
+/*
+ * The PPE and SPE exchange a few 32-bit messages via mailboxes.
+ * All have a 4 bit opcode in the high bits.
+ *
+ * 3 2 1
+ * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | op | arg |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *
+ */
+
+#define MK_MBOX_MSG(cmd, args) ((((cmd) & 0xf) << 28) | ((args) & 0x0fffffff))
+#define MBOX_MSG_OP(msg) (((msg) >> 28) & 0xf)
+#define MBOX_MSG_ARG(msg) ((msg) & 0x0fffffff)
+
+// PPE to SPE (sent via SPE Read Inbound Mailbox)
+
+#define OP_EXIT 0x0 // exit now
+#define OP_GET_SPU_BUFSIZE 0x1
+
+// SPE to PPE (sent via SPE Write Outbound Interrupt Mailbox)
+
+#define OP_JOBS_DONE 0x2 // arg is 0 or 1, indicating which
+ // gc_completion_info_t contains the info
+#define OP_SPU_BUFSIZE 0x3 // arg is max number of bytes
+
+
+#endif /* INCLUDED_GC_MBOX_H */
diff --git a/gcell/src/include/gc_spu_args.h b/gcell/src/include/gc_spu_args.h
new file mode 100644
index 000000000..f5a21227c
--- /dev/null
+++ b/gcell/src/include/gc_spu_args.h
@@ -0,0 +1,60 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 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_SPU_ARGS_H
+#define INCLUDED_GC_SPU_ARGS_H
+
+#include <gc_types.h>
+#include <gc_logging.h>
+
+// args passed to SPE at initialization time
+
+typedef struct gc_spu_args {
+ gc_eaddr_t queue; // address of job queue (gc_jd_queue_t *)
+ gc_eaddr_t comp_info[2]; // completion info (gc_comp_info_t *)
+ uint32_t spu_idx; // which spu we are: [0,nspus-1]
+ uint32_t nspus; // number of spus we're using
+ uint32_t proc_def_ls_addr; // LS addr of proc_def table
+ uint32_t nproc_defs; // number of proc_defs in table
+ gc_log_t log; // logging info
+} _AL16 gc_spu_args_t;
+
+
+#define GC_CI_NJOBS 62 // makes gc_comp_info 1 cache line long
+
+/*!
+ * \brief Used to return info to PPE on which jobs are completed.
+ *
+ * When each SPE is initalized, it is passed EA pointers to two of
+ * these structures. The SPE uses these to communicate which jobs
+ * that it has worked on are complete. The SPE notifies the PPE by
+ * sending an OP_JOBS_DONE message (see gc_mbox.h) with an argument of
+ * 0 or 1, indicating which of the two comp_info's to examine. The
+ * SPE sets the in_use flag to 1 before DMA'ing to the PPE. When the
+ * PPE is done with the structure, it must clear the in_use field to
+ * let the SPE know it can begin using it again.
+ */
+typedef struct gc_comp_info {
+ uint16_t in_use; // set by SPE, cleared by PPE when it's finished
+ uint16_t ncomplete; // number of valid job_id's
+ uint16_t job_id[GC_CI_NJOBS]; // job_id's of completed jobs
+} _AL128 gc_comp_info_t;
+
+#endif /* INCLUDED_GC_SPU_ARGS_H */
diff --git a/gcell/src/include/gc_types.h b/gcell/src/include/gc_types.h
new file mode 100644
index 000000000..9a4d0546e
--- /dev/null
+++ b/gcell/src/include/gc_types.h
@@ -0,0 +1,63 @@
+/* -*- c -*- */
+/*
+ * Copyright 2007 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_TYPES_H
+#define INCLUDED_GC_TYPES_H
+
+#include <stdint.h>
+#include <gc_cdefs.h>
+#include "compiler.h"
+
+__GC_BEGIN_DECLS
+
+#ifndef __cplusplus
+typedef int bool;
+#define true 1
+#define false 0
+#endif
+
+/*!
+ * \brief 64-bit integer type representing an effective address (EA)
+ *
+ * This type is always 64-bits, regardless of whether we're
+ * running in 32 or 64-bit mode.
+ */
+typedef uint64_t gc_eaddr_t;
+
+#if !defined(__SPU__)
+static inline void *
+ea_to_ptr(gc_eaddr_t ea)
+{
+ // in 32-bit mode we're tossing the top 32-bits.
+ return (void *) (uintptr_t) ea;
+}
+
+static inline gc_eaddr_t
+ptr_to_ea(void *p)
+{
+ // two steps to avoid compiler warning in 32-bit mode.
+ return (gc_eaddr_t) (uintptr_t) p;
+}
+#endif
+
+__GC_END_DECLS
+
+#endif /* INCLUDED_GC_TYPES_H */
diff --git a/gcell/src/include/memory_barrier.h b/gcell/src/include/memory_barrier.h
new file mode 100644
index 000000000..b373ffd91
--- /dev/null
+++ b/gcell/src/include/memory_barrier.h
@@ -0,0 +1,66 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 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_MEMORY_BARRIER_H
+#define INCLUDED_MEMORY_BARRIER_H
+
+/*
+ * powerpc memory barriers
+ *
+ * The sync instruction guarantees that all memory accesses initiated
+ * by this processor have been performed (with respect to all other
+ * mechanisms that access memory). The eieio instruction is a barrier
+ * providing an ordering (separately) for (a) cacheable stores and (b)
+ * loads and stores to non-cacheable memory (e.g. I/O devices).
+ *
+ * smp_mb() prevents loads and stores being reordered across this point.
+ * smp_rmb() prevents loads being reordered across this point.
+ * smp_wmb() prevents stores being reordered across this point.
+ *
+ * We have to use the sync instructions for smp_mb(), since lwsync
+ * doesn't order loads with respect to previous stores. Lwsync is
+ * fine for smp_rmb(), though. For smp_wmb(), we use eieio since it
+ * is only used to order updates to system memory.
+ *
+ * For details, see "PowerPC Virtual Environment Architecture, Book
+ * II". Especially Chapter 1, "Storage Model" and Chapter 3, "Storage
+ * Control Instructions." (site:ibm.com)
+ */
+
+#include <ppu_intrinsics.h>
+
+static inline void smp_mb(void)
+{
+ __sync();
+}
+
+static inline void smp_rmb(void)
+{
+ __lwsync();
+}
+
+static inline void smp_wmb(void)
+{
+ __eieio();
+}
+
+
+#endif /* INCLUDED_MEMORY_BARRIER_H */
diff --git a/gcell/src/include/spu/Makefile.am b/gcell/src/include/spu/Makefile.am
new file mode 100644
index 000000000..d202336f7
--- /dev/null
+++ b/gcell/src/include/spu/Makefile.am
@@ -0,0 +1,25 @@
+#
+# Copyright 2007,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.
+#
+
+include $(top_srcdir)/Makefile.common
+
+gcellspuinclude_HEADERS = \
+ gc_delay.h \
+ gc_jd_queue.h
diff --git a/gcell/src/include/spu/gc_delay.h b/gcell/src/include/spu/gc_delay.h
new file mode 100644
index 000000000..78f16fb28
--- /dev/null
+++ b/gcell/src/include/spu/gc_delay.h
@@ -0,0 +1,27 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007,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_DELAY_H
+#define INCLUDED_GC_DELAY_H
+
+void gc_udelay(unsigned int usecs);
+void gc_cdelay(unsigned int cpu_cycles);
+
+#endif /* INCLUDED_GC_DELAY_H */
diff --git a/gcell/src/include/spu/gc_jd_queue.h b/gcell/src/include/spu/gc_jd_queue.h
new file mode 100644
index 000000000..f1ce1b3bd
--- /dev/null
+++ b/gcell/src/include/spu/gc_jd_queue.h
@@ -0,0 +1,57 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 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_SPU_GC_JD_QUEUE_H
+#define INCLUDED_SPU_GC_JD_QUEUE_H
+
+#include "gc_jd_queue_data.h"
+
+/*
+ * Declarations for SPU side of job queue interface
+ */
+
+__GC_BEGIN_DECLS
+
+/*!
+ * \brief Remove and return item at head of queue.
+ *
+ * \param[in] q is EA address of queue structure.
+ * \param[out] item_ea is EA address of item at head of queue.
+ * \param[out] item is local store copy of item at head of queue.
+ * \returns false if the queue is empty, otherwise returns true
+ * and sets \p item_ea and DMA's job descriptor into \p item
+ */
+bool
+gc_jd_queue_dequeue(gc_eaddr_t q, gc_eaddr_t *item_ea, gc_job_desc_t *item);
+
+
+/*!
+ * \brief Get a line reservation on the queue
+ *
+ * \param[in] q is EA address of queue structure.
+ */
+void
+gc_jd_queue_getllar(gc_eaddr_t q);
+
+__GC_END_DECLS
+
+
+#endif /* INCLUDED_SPU_GC_JD_QUEUE_H */