Home | History | Annotate | Line # | Download | only in include
machdep.h revision 1.1.2.5
      1  1.1.2.5  pgoyette /*	$NetBSD: machdep.h,v 1.1.2.5 2018/09/30 01:45:35 pgoyette Exp $	*/
      2  1.1.2.2  pgoyette 
      3  1.1.2.2  pgoyette /*
      4  1.1.2.2  pgoyette  * Copyright (c) 2017 Ryo Shimizu <ryo (at) nerv.org>
      5  1.1.2.2  pgoyette  * All rights reserved.
      6  1.1.2.2  pgoyette  *
      7  1.1.2.2  pgoyette  * Redistribution and use in source and binary forms, with or without
      8  1.1.2.2  pgoyette  * modification, are permitted provided that the following conditions
      9  1.1.2.2  pgoyette  * are met:
     10  1.1.2.2  pgoyette  * 1. Redistributions of source code must retain the above copyright
     11  1.1.2.2  pgoyette  *    notice, this list of conditions and the following disclaimer.
     12  1.1.2.2  pgoyette  * 2. Redistributions in binary form must reproduce the above copyright
     13  1.1.2.2  pgoyette  *    notice, this list of conditions and the following disclaimer in the
     14  1.1.2.2  pgoyette  *    documentation and/or other materials provided with the distribution.
     15  1.1.2.2  pgoyette  *
     16  1.1.2.2  pgoyette  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     17  1.1.2.2  pgoyette  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     18  1.1.2.2  pgoyette  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
     19  1.1.2.2  pgoyette  * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
     20  1.1.2.2  pgoyette  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     21  1.1.2.2  pgoyette  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     22  1.1.2.2  pgoyette  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     23  1.1.2.2  pgoyette  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     24  1.1.2.2  pgoyette  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
     25  1.1.2.2  pgoyette  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     26  1.1.2.2  pgoyette  * POSSIBILITY OF SUCH DAMAGE.
     27  1.1.2.2  pgoyette  */
     28  1.1.2.2  pgoyette 
     29  1.1.2.2  pgoyette #ifndef _AARCH64_MACHDEP_H_
     30  1.1.2.2  pgoyette #define _AARCH64_MACHDEP_H_
     31  1.1.2.2  pgoyette 
     32  1.1.2.2  pgoyette #include <sys/proc.h>
     33  1.1.2.2  pgoyette #include <sys/lwp.h>
     34  1.1.2.2  pgoyette #include <sys/siginfo.h>
     35  1.1.2.2  pgoyette 
     36  1.1.2.2  pgoyette // initarm_common
     37  1.1.2.2  pgoyette #include <machine/bootconfig.h>
     38  1.1.2.2  pgoyette 
     39  1.1.2.5  pgoyette struct boot_physmem;
     40  1.1.2.2  pgoyette 
     41  1.1.2.2  pgoyette static inline paddr_t
     42  1.1.2.2  pgoyette aarch64_kern_vtophys(vaddr_t va)
     43  1.1.2.2  pgoyette {
     44  1.1.2.2  pgoyette 	extern u_long kern_vtopdiff;
     45  1.1.2.2  pgoyette 
     46  1.1.2.2  pgoyette 	return va - kern_vtopdiff;
     47  1.1.2.2  pgoyette }
     48  1.1.2.2  pgoyette 
     49  1.1.2.2  pgoyette static inline vaddr_t
     50  1.1.2.2  pgoyette aarch64_kern_phystov(paddr_t pa)
     51  1.1.2.2  pgoyette {
     52  1.1.2.2  pgoyette 	extern u_long kern_vtopdiff;
     53  1.1.2.2  pgoyette 
     54  1.1.2.2  pgoyette 	return pa + kern_vtopdiff;
     55  1.1.2.2  pgoyette }
     56  1.1.2.2  pgoyette 
     57  1.1.2.2  pgoyette #define KERN_VTOPHYS(va)	aarch64_kern_vtophys(va)
     58  1.1.2.2  pgoyette #define KERN_PHYSTOV(pa)	aarch64_kern_phystov(pa)
     59  1.1.2.2  pgoyette 
     60  1.1.2.2  pgoyette extern paddr_t physical_start;
     61  1.1.2.2  pgoyette extern paddr_t physical_end;
     62  1.1.2.2  pgoyette 
     63  1.1.2.2  pgoyette extern void (*cpu_reset_address0)(void);
     64  1.1.2.2  pgoyette extern void (*cpu_reset_address)(void);
     65  1.1.2.2  pgoyette extern void (*cpu_powerdown_address)(void);
     66  1.1.2.2  pgoyette 
     67  1.1.2.2  pgoyette extern char *booted_kernel;
     68  1.1.2.2  pgoyette 
     69  1.1.2.3  pgoyette #ifdef MULTIPROCESSOR
     70  1.1.2.3  pgoyette extern u_int arm_cpu_max;
     71  1.1.2.3  pgoyette #endif
     72  1.1.2.3  pgoyette 
     73  1.1.2.2  pgoyette vaddr_t initarm_common(vaddr_t, vsize_t, const struct boot_physmem *, size_t);
     74  1.1.2.4  pgoyette void cpu_kernel_vm_init(paddr_t, psize_t);
     75  1.1.2.2  pgoyette 
     76  1.1.2.2  pgoyette void parse_mi_bootargs(char *);
     77  1.1.2.2  pgoyette void dumpsys(void);
     78  1.1.2.2  pgoyette 
     79  1.1.2.2  pgoyette struct trapframe;
     80  1.1.2.2  pgoyette 
     81  1.1.2.2  pgoyette /* fault.c */
     82  1.1.2.3  pgoyette void data_abort_handler(struct trapframe *, uint32_t);
     83  1.1.2.2  pgoyette 
     84  1.1.2.2  pgoyette /* trap.c */
     85  1.1.2.2  pgoyette void lwp_trampoline(void);
     86  1.1.2.2  pgoyette void cpu_dosoftints(void);
     87  1.1.2.2  pgoyette void cpu_switchto_softint(struct lwp *, int);
     88  1.1.2.2  pgoyette void dosoftints(void);
     89  1.1.2.2  pgoyette void trap_doast(struct trapframe *);
     90  1.1.2.2  pgoyette 
     91  1.1.2.2  pgoyette void trap_el1t_sync(struct trapframe *);
     92  1.1.2.2  pgoyette void trap_el1t_irq(struct trapframe *);
     93  1.1.2.2  pgoyette void trap_el1t_fiq(struct trapframe *);
     94  1.1.2.2  pgoyette void trap_el1t_error(struct trapframe *);
     95  1.1.2.2  pgoyette void trap_el1h_sync(struct trapframe *);
     96  1.1.2.2  pgoyette void trap_el1h_fiq(struct trapframe *);
     97  1.1.2.2  pgoyette void trap_el1h_error(struct trapframe *);
     98  1.1.2.2  pgoyette void trap_el0_sync(struct trapframe *);
     99  1.1.2.2  pgoyette void trap_el0_fiq(struct trapframe *);
    100  1.1.2.2  pgoyette void trap_el0_error(struct trapframe *);
    101  1.1.2.2  pgoyette void trap_el0_32sync(struct trapframe *);
    102  1.1.2.2  pgoyette void trap_el0_32fiq(struct trapframe *);
    103  1.1.2.2  pgoyette void trap_el0_32error(struct trapframe *);
    104  1.1.2.2  pgoyette void interrupt(struct trapframe *);
    105  1.1.2.2  pgoyette 
    106  1.1.2.2  pgoyette void ucas_ras_check(struct trapframe *);
    107  1.1.2.2  pgoyette 
    108  1.1.2.2  pgoyette /* cpu_onfault */
    109  1.1.2.2  pgoyette int cpu_set_onfault(struct faultbuf *) __returns_twice;
    110  1.1.2.2  pgoyette void cpu_jump_onfault(struct trapframe *, const struct faultbuf *, int);
    111  1.1.2.2  pgoyette 
    112  1.1.2.5  pgoyette #if defined(_KERNEL)
    113  1.1.2.2  pgoyette static inline void
    114  1.1.2.2  pgoyette cpu_unset_onfault(void)
    115  1.1.2.2  pgoyette {
    116  1.1.2.2  pgoyette 	curlwp->l_md.md_onfault = NULL;
    117  1.1.2.2  pgoyette }
    118  1.1.2.2  pgoyette 
    119  1.1.2.2  pgoyette static inline void
    120  1.1.2.2  pgoyette cpu_enable_onfault(struct faultbuf *fb)
    121  1.1.2.2  pgoyette {
    122  1.1.2.2  pgoyette 	curlwp->l_md.md_onfault = fb;
    123  1.1.2.2  pgoyette }
    124  1.1.2.2  pgoyette 
    125  1.1.2.2  pgoyette static inline struct faultbuf *
    126  1.1.2.2  pgoyette cpu_disable_onfault(void)
    127  1.1.2.2  pgoyette {
    128  1.1.2.2  pgoyette 	struct faultbuf * const fb = curlwp->l_md.md_onfault;
    129  1.1.2.2  pgoyette 	if (fb != NULL)
    130  1.1.2.2  pgoyette 		curlwp->l_md.md_onfault = NULL;
    131  1.1.2.2  pgoyette 	return fb;
    132  1.1.2.2  pgoyette }
    133  1.1.2.5  pgoyette #endif
    134  1.1.2.2  pgoyette 
    135  1.1.2.2  pgoyette /* fpu.c */
    136  1.1.2.2  pgoyette void fpu_attach(struct cpu_info *);
    137  1.1.2.2  pgoyette struct fpreg;
    138  1.1.2.2  pgoyette void load_fpregs(struct fpreg *);
    139  1.1.2.2  pgoyette void save_fpregs(struct fpreg *);
    140  1.1.2.2  pgoyette 
    141  1.1.2.3  pgoyette #ifdef TRAP_SIGDEBUG
    142  1.1.2.3  pgoyette #define do_trapsignal(l, signo, code, addr, trap) \
    143  1.1.2.3  pgoyette     do_trapsignal1(__func__, __LINE__, tf, l, signo, code, addr, trap)
    144  1.1.2.3  pgoyette #else
    145  1.1.2.3  pgoyette #define do_trapsignal(l, signo, code, addr, trap) \
    146  1.1.2.3  pgoyette     do_trapsignal1(l, signo, code, addr, trap)
    147  1.1.2.3  pgoyette #endif
    148  1.1.2.3  pgoyette 
    149  1.1.2.3  pgoyette void do_trapsignal1(
    150  1.1.2.3  pgoyette #ifdef TRAP_SIGDEBUG
    151  1.1.2.3  pgoyette     const char *func, size_t line, struct trapframe *tf,
    152  1.1.2.3  pgoyette #endif
    153  1.1.2.3  pgoyette     struct lwp *l, int signo, int code, void *addr, int trap);
    154  1.1.2.2  pgoyette 
    155  1.1.2.3  pgoyette const char *eclass_trapname(uint32_t);
    156  1.1.2.2  pgoyette 
    157  1.1.2.2  pgoyette #include <sys/pcu.h>
    158  1.1.2.2  pgoyette 
    159  1.1.2.2  pgoyette extern const pcu_ops_t pcu_fpu_ops;
    160  1.1.2.2  pgoyette 
    161  1.1.2.2  pgoyette static inline bool
    162  1.1.2.2  pgoyette fpu_used_p(lwp_t *l)
    163  1.1.2.2  pgoyette {
    164  1.1.2.2  pgoyette 	return pcu_valid_p(&pcu_fpu_ops, l);
    165  1.1.2.2  pgoyette }
    166  1.1.2.2  pgoyette 
    167  1.1.2.2  pgoyette static inline void
    168  1.1.2.2  pgoyette fpu_save(lwp_t *l)
    169  1.1.2.2  pgoyette {
    170  1.1.2.2  pgoyette 	pcu_save(&pcu_fpu_ops, l);
    171  1.1.2.2  pgoyette }
    172  1.1.2.2  pgoyette 
    173  1.1.2.2  pgoyette static inline void
    174  1.1.2.2  pgoyette fpu_load(lwp_t *l)
    175  1.1.2.2  pgoyette {
    176  1.1.2.2  pgoyette 	pcu_load(&pcu_fpu_ops);
    177  1.1.2.2  pgoyette }
    178  1.1.2.2  pgoyette 
    179  1.1.2.2  pgoyette static inline void
    180  1.1.2.2  pgoyette fpu_discard(lwp_t *l, bool usesw)
    181  1.1.2.2  pgoyette {
    182  1.1.2.2  pgoyette 	pcu_discard(&pcu_fpu_ops, l, usesw);
    183  1.1.2.2  pgoyette }
    184  1.1.2.2  pgoyette 
    185  1.1.2.2  pgoyette #endif /* _AARCH64_MACHDEP_H_ */
    186