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