summaryrefslogtreecommitdiff
path: root/spec/common_kern.h
blob: 0cd862f757c464ca4a14d68d56df66d97c988244 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#ifndef _SPEC_COMMON_KERN_H_
#define _SPEC_COMMON_KERN_H_

/*********************************************************************/
/*                                                                   */
/* Interface between Multiboot and our kernel                        */
/*                                                                   */
/*********************************************************************/

/** @brief Query whether we are running as a hypervisor guest.
  *
  * @return True if we are a guest.
  */
int hv_isguest(void);

/** @brief Fetch virtual-address cap set by hypervisor.
  *
  * @return Largest virtual address we are allowed to use.
  */
void *hv_maxvaddr(void);

/** @brief Return total number of frames (each of PAGE_SIZE bytes)
  *        that our machine is currently configured with.
  *
  * @return Frame count.
  */
int machine_phys_frames(void);

#include <boot/multiboot.h>

    /** @brief User kernel entrypoint
     *
     * @param mbinfo The kernel's multiboot information structure.
     * @param argc   Argument count, as parsed from multiboot.
     * @param argv   Argument vector, as parsed from multiboot.
     * @param envp   Environment, as parsed from multiboot.
     *
     * @pre malloc_lmm will have been initialized, stripped of regions that
     *      are potentially hazardous, and bounded between 1 and 16M.
     *
     * @note If you plan to write your own allocator for space, you should
     *       still treat LMM as the official mechanism of getting physical
     *       frames in the kernel region, unless you are planning to parse
     *       the multiboot information and/or e820 yourself.
     */
int kernel_main(mbinfo_t *mbinfo, int argc, char **argv, char **envp);

/*********************************************************************/
/*                                                                   */
/* Kernel memory layout requirements                                 */
/*                                                                   */
/*********************************************************************/

#define USER_MEM_START 0x01000000

#endif /* _SPEC_COMMON_KERN_H_ */