CS350 COS
COS
Loading...
Searching...
No Matches
sga.c
Go to the documentation of this file.
1/*
2 * Copyright (c) 2013-2023 Ali Mashtizadeh
3 * All rights reserved.
4 */
5
6#include <stdint.h>
7
8#include <sys/kassert.h>
9#include <sys/sga.h>
10
11void
13{
14 sga->len = 0;
15}
16
17int
19{
21
22 sga->entries[sga->len].offset = off;
23 sga->entries[sga->len].length = len;
24 sga->len++;
25
26 return sga->len;
27}
28
29void
31{
32 int i;
33
34 kprintf("--- SGArray Begin ---\n");
35 for (i = 0; i < sga->len; i++)
36 {
37 kprintf("%d: %016llx %016llx\n", i, sga->entries[i].offset,
38 sga->entries[i].length);
39 }
40 kprintf("--- SGArray End ---\n");
41}
42
#define ASSERT(_x)
Definition: kassert.h:8
int kprintf(const char *fmt,...)
Definition: printf.c:210
uint64_t len
Definition: multiboot.h:2
void SGArray_Dump(SGArray *sga)
Definition: sga.c:30
void SGArray_Init(SGArray *sga)
Definition: sga.c:12
int SGArray_Append(SGArray *sga, uint64_t off, uint64_t len)
Definition: sga.c:18
uint64_t length
Definition: sga.h:10
#define SGARRAY_MAX_ENTRIES
Definition: sga.h:5
SGEntry entries[SGARRAY_MAX_ENTRIES]
Definition: sga.h:16
uint32_t len
Definition: sga.h:15
uint64_t offset
Definition: sga.h:9
Definition: sga.h:14
unsigned long uint64_t
Definition: types.h:13