metal-cos/sys/kern/sga.c

43 lines
699 B
C
Raw Normal View History

2023-09-10 20:12:25 +00:00
/*
* Copyright (c) 2013-2023 Ali Mashtizadeh
* All rights reserved.
*/
#include <stdint.h>
#include <sys/kassert.h>
#include <sys/sga.h>
void
SGArray_Init(SGArray *sga)
{
sga->len = 0;
}
int
SGArray_Append(SGArray *sga, uint64_t off, uint64_t len)
{
ASSERT(sga->len < SGARRAY_MAX_ENTRIES)
sga->entries[sga->len].offset = off;
sga->entries[sga->len].length = len;
sga->len++;
return sga->len;
}
void
SGArray_Dump(SGArray *sga)
{
2024-10-04 05:55:19 +00:00
unsigned int i;
kprintf("--- SGArray Begin ---\n");
for (i = 0; i < sga->len; i++)
{
kprintf("%d: %016llx %016llx\n", i, sga->entries[i].offset,
sga->entries[i].length);
}
kprintf("--- SGArray End ---\n");
}