spu.h
来自「linux 内核源代码」· C头文件 代码 · 共 711 行 · 第 1/2 页
H
711 行
/* * SPU core / file system interface and HW structures * * (C) Copyright IBM Deutschland Entwicklung GmbH 2005 * * Author: Arnd Bergmann <arndb@de.ibm.com> * * This program 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 2, or (at your option) * any later version. * * This program 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., 675 Mass Ave, Cambridge, MA 02139, USA. */#ifndef _SPU_H#define _SPU_H#ifdef __KERNEL__#include <linux/workqueue.h>#include <linux/sysdev.h>#define LS_SIZE (256 * 1024)#define LS_ADDR_MASK (LS_SIZE - 1)#define MFC_PUT_CMD 0x20#define MFC_PUTS_CMD 0x28#define MFC_PUTR_CMD 0x30#define MFC_PUTF_CMD 0x22#define MFC_PUTB_CMD 0x21#define MFC_PUTFS_CMD 0x2A#define MFC_PUTBS_CMD 0x29#define MFC_PUTRF_CMD 0x32#define MFC_PUTRB_CMD 0x31#define MFC_PUTL_CMD 0x24#define MFC_PUTRL_CMD 0x34#define MFC_PUTLF_CMD 0x26#define MFC_PUTLB_CMD 0x25#define MFC_PUTRLF_CMD 0x36#define MFC_PUTRLB_CMD 0x35#define MFC_GET_CMD 0x40#define MFC_GETS_CMD 0x48#define MFC_GETF_CMD 0x42#define MFC_GETB_CMD 0x41#define MFC_GETFS_CMD 0x4A#define MFC_GETBS_CMD 0x49#define MFC_GETL_CMD 0x44#define MFC_GETLF_CMD 0x46#define MFC_GETLB_CMD 0x45#define MFC_SDCRT_CMD 0x80#define MFC_SDCRTST_CMD 0x81#define MFC_SDCRZ_CMD 0x89#define MFC_SDCRS_CMD 0x8D#define MFC_SDCRF_CMD 0x8F#define MFC_GETLLAR_CMD 0xD0#define MFC_PUTLLC_CMD 0xB4#define MFC_PUTLLUC_CMD 0xB0#define MFC_PUTQLLUC_CMD 0xB8#define MFC_SNDSIG_CMD 0xA0#define MFC_SNDSIGB_CMD 0xA1#define MFC_SNDSIGF_CMD 0xA2#define MFC_BARRIER_CMD 0xC0#define MFC_EIEIO_CMD 0xC8#define MFC_SYNC_CMD 0xCC#define MFC_MIN_DMA_SIZE_SHIFT 4 /* 16 bytes */#define MFC_MAX_DMA_SIZE_SHIFT 14 /* 16384 bytes */#define MFC_MIN_DMA_SIZE (1 << MFC_MIN_DMA_SIZE_SHIFT)#define MFC_MAX_DMA_SIZE (1 << MFC_MAX_DMA_SIZE_SHIFT)#define MFC_MIN_DMA_SIZE_MASK (MFC_MIN_DMA_SIZE - 1)#define MFC_MAX_DMA_SIZE_MASK (MFC_MAX_DMA_SIZE - 1)#define MFC_MIN_DMA_LIST_SIZE 0x0008 /* 8 bytes */#define MFC_MAX_DMA_LIST_SIZE 0x4000 /* 16K bytes */#define MFC_TAGID_TO_TAGMASK(tag_id) (1 << (tag_id & 0x1F))/* Events for Channels 0-2 */#define MFC_DMA_TAG_STATUS_UPDATE_EVENT 0x00000001#define MFC_DMA_TAG_CMD_STALL_NOTIFY_EVENT 0x00000002#define MFC_DMA_QUEUE_AVAILABLE_EVENT 0x00000008#define MFC_SPU_MAILBOX_WRITTEN_EVENT 0x00000010#define MFC_DECREMENTER_EVENT 0x00000020#define MFC_PU_INT_MAILBOX_AVAILABLE_EVENT 0x00000040#define MFC_PU_MAILBOX_AVAILABLE_EVENT 0x00000080#define MFC_SIGNAL_2_EVENT 0x00000100#define MFC_SIGNAL_1_EVENT 0x00000200#define MFC_LLR_LOST_EVENT 0x00000400#define MFC_PRIV_ATTN_EVENT 0x00000800#define MFC_MULTI_SRC_EVENT 0x00001000/* Flags indicating progress during context switch. */#define SPU_CONTEXT_SWITCH_PENDING 0UL#define SPU_CONTEXT_SWITCH_ACTIVE 1ULstruct spu_context;struct spu_runqueue;struct device_node;enum spu_utilization_state { SPU_UTIL_USER, SPU_UTIL_SYSTEM, SPU_UTIL_IOWAIT, SPU_UTIL_IDLE_LOADED, SPU_UTIL_MAX};struct spu { const char *name; unsigned long local_store_phys; u8 *local_store; unsigned long problem_phys; struct spu_problem __iomem *problem; struct spu_priv2 __iomem *priv2; struct list_head cbe_list; struct list_head full_list; enum { SPU_FREE, SPU_USED } alloc_state; int number; unsigned int irqs[3]; u32 node; u64 flags; u64 dar; u64 dsisr; u64 class_0_pending; size_t ls_size; unsigned int slb_replace; struct mm_struct *mm; struct spu_context *ctx; struct spu_runqueue *rq; unsigned long long timestamp; pid_t pid; pid_t tgid; spinlock_t register_lock; void (* wbox_callback)(struct spu *spu); void (* ibox_callback)(struct spu *spu); void (* stop_callback)(struct spu *spu); void (* mfc_callback)(struct spu *spu); void (* dma_callback)(struct spu *spu, int type); char irq_c0[8]; char irq_c1[8]; char irq_c2[8]; u64 spe_id; void* pdata; /* platform private data */ /* of based platforms only */ struct device_node *devnode; /* native only */ struct spu_priv1 __iomem *priv1; /* beat only */ u64 shadow_int_mask_RW[3]; struct sys_device sysdev; int has_mem_affinity; struct list_head aff_list; struct { /* protected by interrupt reentrancy */ enum spu_utilization_state util_state; unsigned long long tstamp; unsigned long long times[SPU_UTIL_MAX]; unsigned long long vol_ctx_switch; unsigned long long invol_ctx_switch; unsigned long long min_flt; unsigned long long maj_flt; unsigned long long hash_flt; unsigned long long slb_flt; unsigned long long class2_intr; unsigned long long libassist; } stats;};struct cbe_spu_info { struct mutex list_mutex; struct list_head spus; int n_spus; int nr_active; atomic_t reserved_spus;};extern struct cbe_spu_info cbe_spu_info[];void spu_init_channels(struct spu *spu);int spu_irq_class_0_bottom(struct spu *spu);int spu_irq_class_1_bottom(struct spu *spu);void spu_irq_setaffinity(struct spu *spu, int cpu);#ifdef CONFIG_KEXECvoid crash_register_spus(struct list_head *list);#elsestatic inline void crash_register_spus(struct list_head *list){}#endifextern void spu_invalidate_slbs(struct spu *spu);extern void spu_associate_mm(struct spu *spu, struct mm_struct *mm);/* Calls from the memory management to the SPU */struct mm_struct;extern void spu_flush_all_slbs(struct mm_struct *mm);/* This interface allows a profiler (e.g., OProfile) to store a ref * to spu context information that it creates. This caching technique * avoids the need to recreate this information after a save/restore operation. * * Assumes the caller has already incremented the ref count to * profile_info; then spu_context_destroy must call kref_put * on prof_info_kref. */void spu_set_profile_private_kref(struct spu_context *ctx, struct kref *prof_info_kref, void ( * prof_info_release) (struct kref *kref));void *spu_get_profile_private_kref(struct spu_context *ctx);/* system callbacks from the SPU */struct spu_syscall_block { u64 nr_ret; u64 parm[6];};extern long spu_sys_callback(struct spu_syscall_block *s);/* syscalls implemented in spufs */struct file;struct spufs_calls { long (*create_thread)(const char __user *name, unsigned int flags, mode_t mode, struct file *neighbor); long (*spu_run)(struct file *filp, __u32 __user *unpc, __u32 __user *ustatus); int (*coredump_extra_notes_size)(void); int (*coredump_extra_notes_write)(struct file *file, loff_t *foffset); void (*notify_spus_active)(void); struct module *owner;};/* return status from spu_run, same as in libspe */#define SPE_EVENT_DMA_ALIGNMENT 0x0008 /*A DMA alignment error */#define SPE_EVENT_SPE_ERROR 0x0010 /*An illegal instruction error*/#define SPE_EVENT_SPE_DATA_SEGMENT 0x0020 /*A DMA segmentation error */#define SPE_EVENT_SPE_DATA_STORAGE 0x0040 /*A DMA storage error */#define SPE_EVENT_INVALID_DMA 0x0800 /* Invalid MFC DMA *//* * Flags for sys_spu_create. */#define SPU_CREATE_EVENTS_ENABLED 0x0001#define SPU_CREATE_GANG 0x0002#define SPU_CREATE_NOSCHED 0x0004#define SPU_CREATE_ISOLATE 0x0008#define SPU_CREATE_AFFINITY_SPU 0x0010#define SPU_CREATE_AFFINITY_MEM 0x0020#define SPU_CREATE_FLAG_ALL 0x003f /* mask of all valid flags */int register_spu_syscalls(struct spufs_calls *calls);void unregister_spu_syscalls(struct spufs_calls *calls);int spu_add_sysdev_attr(struct sysdev_attribute *attr);void spu_remove_sysdev_attr(struct sysdev_attribute *attr);int spu_add_sysdev_attr_group(struct attribute_group *attrs);void spu_remove_sysdev_attr_group(struct attribute_group *attrs);/* * Notifier blocks: * * oprofile can get notified when a context switch is performed * on an spe. The notifer function that gets called is passed * a pointer to the SPU structure as well as the object-id that * identifies the binary running on that SPU now. * * For a context save, the object-id that is passed is zero, * identifying that the kernel will run from that moment on. * * For a context restore, the object-id is the value written * to object-id spufs file from user space and the notifer * function can assume that spu->ctx is valid. */struct notifier_block;int spu_switch_event_register(struct notifier_block * n);int spu_switch_event_unregister(struct notifier_block * n);extern void notify_spus_active(void);extern void do_notify_spus_active(void);/* * This defines the Local Store, Problem Area and Privlege Area of an SPU. */union mfc_tag_size_class_cmd { struct { u16 mfc_size; u16 mfc_tag; u8 pad; u8 mfc_rclassid; u16 mfc_cmd; } u; struct { u32 mfc_size_tag32; u32 mfc_class_cmd32; } by32; u64 all64;};struct mfc_cq_sr { u64 mfc_cq_data0_RW; u64 mfc_cq_data1_RW; u64 mfc_cq_data2_RW; u64 mfc_cq_data3_RW;};struct spu_problem {#define MS_SYNC_PENDING 1L u64 spc_mssync_RW; /* 0x0000 */ u8 pad_0x0008_0x3000[0x3000 - 0x0008]; /* DMA Area */ u8 pad_0x3000_0x3004[0x4]; /* 0x3000 */ u32 mfc_lsa_W; /* 0x3004 */ u64 mfc_ea_W; /* 0x3008 */ union mfc_tag_size_class_cmd mfc_union_W; /* 0x3010 */ u8 pad_0x3018_0x3104[0xec]; /* 0x3018 */ u32 dma_qstatus_R; /* 0x3104 */ u8 pad_0x3108_0x3204[0xfc]; /* 0x3108 */ u32 dma_querytype_RW; /* 0x3204 */ u8 pad_0x3208_0x321c[0x14]; /* 0x3208 */ u32 dma_querymask_RW; /* 0x321c */ u8 pad_0x3220_0x322c[0xc]; /* 0x3220 */ u32 dma_tagstatus_R; /* 0x322c */#define DMA_TAGSTATUS_INTR_ANY 1u#define DMA_TAGSTATUS_INTR_ALL 2u u8 pad_0x3230_0x4000[0x4000 - 0x3230]; /* 0x3230 */ /* SPU Control Area */ u8 pad_0x4000_0x4004[0x4]; /* 0x4000 */ u32 pu_mb_R; /* 0x4004 */ u8 pad_0x4008_0x400c[0x4]; /* 0x4008 */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?