Home | History | Annotate | Line # | Download | only in prekern
      1  1.25  mlelstv /*	$NetBSD: prekern.h,v 1.25 2022/08/21 14:05:52 mlelstv Exp $	*/
      2   1.1     maxv 
      3   1.1     maxv /*
      4  1.23     maxv  * Copyright (c) 2017-2020 The NetBSD Foundation, Inc. All rights reserved.
      5   1.1     maxv  *
      6   1.1     maxv  * This code is derived from software contributed to The NetBSD Foundation
      7   1.1     maxv  * by Maxime Villard.
      8   1.1     maxv  *
      9   1.1     maxv  * Redistribution and use in source and binary forms, with or without
     10   1.1     maxv  * modification, are permitted provided that the following conditions
     11   1.1     maxv  * are met:
     12   1.1     maxv  * 1. Redistributions of source code must retain the above copyright
     13   1.1     maxv  *    notice, this list of conditions and the following disclaimer.
     14   1.1     maxv  * 2. Redistributions in binary form must reproduce the above copyright
     15   1.1     maxv  *    notice, this list of conditions and the following disclaimer in the
     16   1.1     maxv  *    documentation and/or other materials provided with the distribution.
     17   1.1     maxv  *
     18   1.1     maxv  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     19   1.1     maxv  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     20   1.1     maxv  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     21   1.1     maxv  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     22   1.1     maxv  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     23   1.1     maxv  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     24   1.1     maxv  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     25   1.1     maxv  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     26   1.1     maxv  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     27   1.1     maxv  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     28   1.1     maxv  * POSSIBILITY OF SUCH DAMAGE.
     29   1.1     maxv  */
     30   1.1     maxv 
     31   1.1     maxv #include <sys/cdefs.h>
     32   1.1     maxv #include <sys/param.h>
     33   1.1     maxv #include <sys/stdbool.h>
     34  1.10     maxv #include <lib/libkern/libkern.h>
     35  1.25  mlelstv 
     36  1.25  mlelstv #include <machine/pmap.h>
     37   1.1     maxv #include <machine/pte.h>
     38   1.1     maxv 
     39  1.25  mlelstv #include <x86/bootspace.h>
     40  1.25  mlelstv 
     41   1.1     maxv #include "pdir.h"
     42   1.1     maxv #include "redef.h"
     43   1.1     maxv 
     44  1.21     maxv #define ASSERT(a) if (!(a)) fatal("ASSERT: " #a);
     45   1.1     maxv typedef uint64_t pte_prot_t;
     46   1.1     maxv #define WHITE_ON_BLACK 0x07
     47   1.1     maxv #define RED_ON_BLACK 0x04
     48   1.1     maxv #define GREEN_ON_BLACK 0x02
     49  1.24  khorben #define YELLOW_ON_BLACK 0x0e
     50   1.1     maxv 
     51   1.3     maxv #define HEAD_WINDOW_BASE	(KERNBASE - NBPD_L3)
     52   1.3     maxv #define HEAD_WINDOW_SIZE	NBPD_L3
     53   1.3     maxv 
     54   1.1     maxv #define KASLR_WINDOW_BASE	KERNBASE		/* max - 2GB */
     55   1.1     maxv #define KASLR_WINDOW_SIZE	(2LLU * (1 << 30))	/* 2GB */
     56   1.1     maxv 
     57  1.24  khorben typedef enum
     58  1.24  khorben {
     59  1.24  khorben 	STATE_NORMAL = 0,
     60  1.24  khorben 	STATE_ERROR,
     61  1.24  khorben 	STATE_WARNING
     62  1.24  khorben } state_t;
     63  1.24  khorben 
     64   1.1     maxv /* -------------------------------------------------------------------------- */
     65   1.1     maxv 
     66   1.1     maxv /* console.c */
     67  1.12     maxv void init_cons(void);
     68   1.1     maxv void print_ext(int, char *);
     69   1.1     maxv void print(char *);
     70  1.24  khorben void print_state(state_t, char *);
     71  1.12     maxv void print_banner(void);
     72   1.1     maxv 
     73   1.1     maxv /* elf.c */
     74   1.3     maxv size_t elf_get_head_size(vaddr_t);
     75   1.3     maxv void elf_build_head(vaddr_t);
     76  1.22     maxv void elf_fixup_boot(vaddr_t, paddr_t);
     77  1.12     maxv void elf_map_sections(void);
     78  1.22     maxv void elf_build_info(void);
     79  1.12     maxv vaddr_t elf_kernel_reloc(void);
     80   1.1     maxv 
     81   1.1     maxv /* locore.S */
     82   1.7     maxv void cpuid(uint32_t, uint32_t, uint32_t *);
     83   1.1     maxv void lidt(void *);
     84  1.12     maxv uint64_t rdtsc(void);
     85   1.7     maxv int rdseed(uint64_t *);
     86  1.17     maxv int rdrand(uint64_t *);
     87  1.12     maxv void jump_kernel(vaddr_t);
     88   1.1     maxv 
     89   1.1     maxv /* mm.c */
     90   1.1     maxv void mm_init(paddr_t);
     91  1.12     maxv void mm_bootspace_mprotect(void);
     92  1.13     maxv vaddr_t mm_map_segment(int, paddr_t, size_t, size_t);
     93  1.12     maxv void mm_map_kernel(void);
     94   1.1     maxv 
     95   1.1     maxv /* prekern.c */
     96   1.1     maxv void fatal(char *);
     97  1.18     maxv 
     98  1.18     maxv /* prng.c */
     99  1.18     maxv void prng_init(void);
    100  1.18     maxv void prng_get_rand(void *, size_t);
    101