Home | History | Annotate | Line # | Download | only in pic
picvar.h revision 1.7.4.1
      1  1.7.4.1  rmind /*	$NetBSD: picvar.h,v 1.7.4.1 2014/05/18 17:44:59 rmind Exp $	*/
      2      1.2   matt /*-
      3      1.2   matt  * Copyright (c) 2008 The NetBSD Foundation, Inc.
      4      1.2   matt  * All rights reserved.
      5      1.2   matt  *
      6      1.2   matt  * This code is derived from software contributed to The NetBSD Foundation
      7      1.2   matt  * by Matt Thomas.
      8      1.2   matt  *
      9      1.2   matt  * Redistribution and use in source and binary forms, with or without
     10      1.2   matt  * modification, are permitted provided that the following conditions
     11      1.2   matt  * are met:
     12      1.2   matt  * 1. Redistributions of source code must retain the above copyright
     13      1.2   matt  *    notice, this list of conditions and the following disclaimer.
     14      1.2   matt  * 2. Redistributions in binary form must reproduce the above copyright
     15      1.2   matt  *    notice, this list of conditions and the following disclaimer in the
     16      1.2   matt  *    documentation and/or other materials provided with the distribution.
     17      1.2   matt  *
     18      1.2   matt  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     19      1.2   matt  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     20      1.2   matt  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     21      1.2   matt  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     22      1.2   matt  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     23      1.2   matt  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     24      1.2   matt  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     25      1.2   matt  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     26      1.2   matt  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     27      1.2   matt  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     28      1.2   matt  * POSSIBILITY OF SUCH DAMAGE.
     29      1.2   matt  */
     30      1.2   matt #ifndef _ARM_PIC_PICVAR_H_
     31      1.2   matt #define _ARM_PIC_PICVAR_H_
     32      1.2   matt 
     33      1.7   matt #ifdef MULTIPROCESSOR
     34      1.7   matt #include <sys/kcpuset.h>
     35      1.7   matt #endif
     36      1.7   matt 
     37      1.2   matt int	_splraise(int);
     38      1.2   matt int	_spllower(int);
     39      1.2   matt void	splx(int);
     40      1.2   matt const char *
     41      1.2   matt 	intr_typename(int);
     42      1.2   matt 
     43      1.2   matt struct pic_softc;
     44      1.2   matt struct intrsource;
     45      1.7   matt struct cpu_info;
     46      1.7   matt 
     47      1.7   matt #define	IPI_AST			0	/* just get an interrupt */
     48      1.7   matt #define	IPI_XCALL		1	/* xcall */
     49      1.7   matt #define	IPI_NOP			2	/* just get an interrupt (armv6) */
     50  1.7.4.1  rmind #define	IPI_SHOOTDOWN		3	/* cause a tlb shootdown */
     51  1.7.4.1  rmind #define	IPI_DDB			4	/* enter DDB */
     52  1.7.4.1  rmind #ifdef __HAVE_PREEMPTION
     53  1.7.4.1  rmind #define	IPI_KPREEMPT		5	/* cause a preemption */
     54  1.7.4.1  rmind #define	NIPI			6
     55      1.7   matt #else
     56  1.7.4.1  rmind #define	NIPI			5
     57      1.7   matt #endif
     58      1.2   matt 
     59      1.2   matt int	pic_handle_intr(void *);
     60      1.2   matt void	pic_mark_pending(struct pic_softc *pic, int irq);
     61      1.2   matt void	pic_mark_pending_source(struct pic_softc *pic, struct intrsource *is);
     62      1.2   matt uint32_t pic_mark_pending_sources(struct pic_softc *pic, size_t irq_base,
     63      1.2   matt 	    uint32_t pending);
     64      1.2   matt void	*pic_establish_intr(struct pic_softc *pic, int irq, int ipl, int type,
     65      1.2   matt 	    int (*func)(void *), void *arg);
     66      1.2   matt int	pic_alloc_irq(struct pic_softc *pic);
     67      1.2   matt void	pic_disestablish_source(struct intrsource *is);
     68      1.2   matt void	pic_do_pending_ints(register_t psw, int newipl, void *frame);
     69      1.2   matt void	pic_dispatch(struct intrsource *is, void *frame);
     70      1.2   matt 
     71      1.2   matt void	*intr_establish(int irq, int ipl, int type, int (*func)(void *),
     72      1.2   matt 	    void *arg);
     73      1.2   matt void	intr_disestablish(void *);
     74      1.7   matt #ifdef MULTIPROCESSOR
     75      1.7   matt void	intr_cpu_init(struct cpu_info *);
     76      1.7   matt void	intr_ipi_send(const kcpuset_t *, u_long ipi);
     77      1.7   matt #endif
     78      1.2   matt 
     79      1.2   matt #ifdef _INTR_PRIVATE
     80      1.2   matt 
     81      1.7   matt #include "opt_arm_intr_impl.h"
     82      1.7   matt 
     83      1.5    bsh #include <sys/evcnt.h>
     84      1.7   matt #include <sys/percpu.h>
     85      1.5    bsh 
     86      1.2   matt #ifndef PIC_MAXPICS
     87      1.2   matt #define PIC_MAXPICS	32
     88      1.2   matt #endif
     89      1.2   matt #ifndef PIC_MAXSOURCES
     90      1.2   matt #define	PIC_MAXSOURCES	64
     91      1.2   matt #endif
     92      1.2   matt #ifndef PIC_MAXMAXSOURCES
     93      1.2   matt #define	PIC_MAXMAXSOURCES	128
     94      1.2   matt #endif
     95      1.2   matt 
     96      1.2   matt struct intrsource {
     97      1.2   matt 	int (*is_func)(void *);
     98      1.2   matt 	void *is_arg;
     99      1.2   matt 	struct pic_softc *is_pic;		/* owning PIC */
    100      1.2   matt 	uint8_t is_type;			/* IST_xxx */
    101      1.2   matt 	uint8_t is_ipl;				/* IPL_xxx */
    102      1.2   matt 	uint8_t is_irq;				/* local to pic */
    103      1.2   matt 	uint8_t is_iplidx;
    104  1.7.4.1  rmind 	bool is_mpsafe;
    105      1.2   matt 	char is_source[16];
    106      1.2   matt };
    107      1.2   matt 
    108      1.7   matt struct pic_percpu {
    109      1.7   matt 	struct evcnt *pcpu_evs;
    110      1.7   matt 	char *pcpu_name;
    111      1.7   matt 	uint32_t pcpu_magic;
    112      1.7   matt };
    113      1.7   matt 
    114      1.7   matt #define	PICPERCPU_MAGIC		0xfeedface
    115      1.7   matt 
    116      1.2   matt struct pic_softc {
    117      1.2   matt 	const struct pic_ops *pic_ops;
    118      1.2   matt 	struct intrsource **pic_sources;
    119      1.4   matt 	volatile uint32_t pic_pending_irqs[(PIC_MAXSOURCES + 31) / 32];
    120      1.4   matt 	volatile uint32_t pic_blocked_irqs[(PIC_MAXSOURCES + 31) / 32];
    121      1.4   matt 	volatile uint32_t pic_pending_ipls;
    122      1.2   matt 	size_t pic_maxsources;
    123      1.7   matt 	percpu_t *pic_percpu;
    124      1.2   matt 	uint8_t pic_id;
    125      1.2   matt 	int16_t pic_irqbase;
    126      1.2   matt 	char pic_name[14];
    127      1.2   matt };
    128      1.2   matt 
    129      1.2   matt struct pic_ops {
    130      1.2   matt 	void (*pic_unblock_irqs)(struct pic_softc *, size_t, uint32_t);
    131      1.2   matt 	void (*pic_block_irqs)(struct pic_softc *, size_t, uint32_t);
    132      1.2   matt 	int (*pic_find_pending_irqs)(struct pic_softc *);
    133      1.2   matt 
    134      1.2   matt 	void (*pic_establish_irq)(struct pic_softc *, struct intrsource *);
    135      1.2   matt 	void (*pic_source_name)(struct pic_softc *, int, char *, size_t);
    136      1.6   matt 
    137      1.6   matt #ifdef __HAVE_PIC_SET_PRIORITY
    138      1.6   matt 	void (*pic_set_priority)(struct pic_softc *, int);
    139      1.6   matt #endif
    140      1.7   matt #ifdef MULTIPROCESSOR
    141      1.7   matt 	void (*pic_cpu_init)(struct pic_softc *, struct cpu_info *);
    142      1.7   matt 	void (*pic_ipi_send)(struct pic_softc *, const kcpuset_t *, u_long);
    143      1.7   matt #endif
    144      1.2   matt };
    145      1.2   matt 
    146      1.6   matt #ifdef __HAVE_PIC_SET_PRIORITY
    147      1.6   matt /*
    148      1.6   matt  * This is used to update a hardware pic with a value corresponding
    149      1.6   matt  * to the ipl being set.
    150      1.6   matt  */
    151      1.6   matt struct cpu_info;
    152      1.6   matt void	pic_set_priority(struct cpu_info *, int);
    153      1.6   matt #else
    154      1.6   matt /* Using an inline causes catch-22 problems with cpu.h */
    155      1.6   matt #define	pic_set_priority(ci, newipl)	((void)((ci)->ci_cpl = (newipl)))
    156      1.6   matt #endif
    157      1.2   matt 
    158      1.2   matt void	pic_add(struct pic_softc *, int);
    159      1.2   matt void	pic_do_pending_int(void);
    160      1.7   matt #ifdef MULTIPROCESSOR
    161      1.7   matt int	pic_ipi_nop(void *);
    162      1.7   matt int	pic_ipi_xcall(void *);
    163  1.7.4.1  rmind int	pic_ipi_shootdown(void *);
    164  1.7.4.1  rmind int	pic_ipi_ddb(void *);
    165      1.7   matt #endif
    166      1.7   matt #ifdef __HAVE_PIC_FAST_SOFTINTS
    167      1.7   matt int	pic_handle_softint(void *);
    168      1.7   matt #endif
    169      1.2   matt 
    170      1.2   matt extern struct pic_softc * pic_list[PIC_MAXPICS];
    171      1.2   matt #endif /* _INTR_PRIVATE */
    172      1.2   matt 
    173      1.2   matt #endif /* _ARM_PIC_PICVAR_H_ */
    174