OurOS 0.1
Operating System built by McGill Students
 
Loading...
Searching...
No Matches
frame.h
Go to the documentation of this file.
1#ifndef FRAME_H
2#define FRAME_H
3
4#include <stddef.h>
5#include <stdint.h>
6
7/**
8 * @brief Metadata for a physical frame.
9 */
10struct frame;
11
12/**
13 * @brief Allocates a frame and returns a pointer to it.
14 * The allocated frame will be zeroed out.
15 *
16 * @param identifier A string identifier for the frame (for debugging purposes).
17 * @return A pointer to the allocated frame.
18 */
19struct frame *alloc_frame(const char *identifier);
20/**
21 * @brief Frees a frame.
22 *
23 * @param frame A pointer to the frame to free.
24 * @note The frame will only be truly freed if its reference count drops to 0.
25 */
26void free_frame(struct frame *frame);
27
28/**
29 * @brief Returns the PFN of a frame.
30 *
31 * @param frame A pointer to the frame.
32 * @return The PFN of the frame.
33 */
34size_t frame_to_pfn(struct frame *frame);
35/**
36 * @brief Converts a PFN to a physical address.
37 *
38 * @param pfn The PFN to convert.
39 * @return The physical address.
40 */
41size_t pfn_to_phys(size_t pfn);
42
43/**
44 * @brief Initializes the frame allocator and memory map.
45 */
46void frame_init();
47
48#endif
void free_frame(struct frame *frame)
Frees a frame.
Definition frame.c:95
size_t pfn_to_phys(size_t pfn)
Converts a PFN to a physical address.
Definition frame.c:78
void frame_init()
Initializes the frame allocator and memory map.
Definition frame.c:229
struct frame * alloc_frame(const char *identifier)
Allocates a frame and returns a pointer to it. The allocated frame will be zeroed out.
Definition frame.c:83
size_t frame_to_pfn(struct frame *frame)
Returns the PFN of a frame.
Definition frame.c:103
Metadata for a physical frame.
Definition frame.c:14
size_t pfn
Definition frame.c:17
const char * identifier
Definition frame.c:18