Compare commits
No commits in common. "435b712f2542f62c8325844125ea750bc36c3288" and "c72bce50ac86c8eb473212a529679a902b686baf" have entirely different histories.
435b712f25
...
c72bce50ac
3 changed files with 10 additions and 50 deletions
|
|
@ -1,26 +0,0 @@
|
||||||
/* Support signed or unsigned plain-char */
|
|
||||||
|
|
||||||
#if '\xff' > 0
|
|
||||||
#define CHAR_MIN 0
|
|
||||||
#define CHAR_MAX 255
|
|
||||||
#else
|
|
||||||
#define CHAR_MIN (-128)
|
|
||||||
#define CHAR_MAX 127
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define CHAR_BIT 8
|
|
||||||
#define SCHAR_MIN (-128)
|
|
||||||
#define SCHAR_MAX 127
|
|
||||||
#define UCHAR_MAX 255
|
|
||||||
#define SHRT_MIN (-1 - 0x7fff)
|
|
||||||
#define SHRT_MAX 0x7fff
|
|
||||||
#define USHRT_MAX 0xffff
|
|
||||||
#define INT_MIN (-1 - 0x7fffffff)
|
|
||||||
#define INT_MAX 0x7fffffff
|
|
||||||
#define UINT_MAX 0xffffffffU
|
|
||||||
#define LONG_MIN (-LONG_MAX - 1)
|
|
||||||
#define LONG_MAX __LONG_MAX
|
|
||||||
#define ULONG_MAX (2UL * LONG_MAX + 1)
|
|
||||||
#define LLONG_MIN (-LLONG_MAX - 1)
|
|
||||||
#define LLONG_MAX 0x7fffffffffffffffLL
|
|
||||||
#define ULLONG_MAX (2ULL * LLONG_MAX + 1)
|
|
||||||
|
|
@ -154,10 +154,15 @@ char *itoa(int value, char *str, int base) {
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
int memcmp(const void *vl, const void *vr, size_t n) {
|
int memcmp(const void *s1, const void *s2, size_t len) {
|
||||||
const unsigned char *l = vl, *r = vr;
|
const u8 *a = (const u8 *)s1;
|
||||||
for (; n && *l == *r; n--, l++, r++);
|
const u8 *b = (const u8 *)s2;
|
||||||
return n ? *l - *r : 0;
|
for (size_t i = 0; i < len; i++) {
|
||||||
|
if (a[i] != b[i]) {
|
||||||
|
return (int)a[i] - (int)b[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t strlen(const char *s) {
|
size_t strlen(const char *s) {
|
||||||
|
|
|
||||||
21
kern/start.c
21
kern/start.c
|
|
@ -2,7 +2,6 @@
|
||||||
#include <banner.h>
|
#include <banner.h>
|
||||||
#include <buddy.h>
|
#include <buddy.h>
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <freelist.h>
|
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
#include <panic.h>
|
#include <panic.h>
|
||||||
#include <proc.h>
|
#include <proc.h>
|
||||||
|
|
@ -12,7 +11,6 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <uart.h>
|
#include <uart.h>
|
||||||
#include <util.h>
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allocate one stack per CPU (hart).
|
* Allocate one stack per CPU (hart).
|
||||||
|
|
@ -41,7 +39,7 @@ void start() {
|
||||||
// cpu (struct Cpu).
|
// cpu (struct Cpu).
|
||||||
write_tp(id);
|
write_tp(id);
|
||||||
|
|
||||||
if (unlikely(id == 0)) {
|
if (id == 0) {
|
||||||
/* Here we will do a bunch of initialization steps */
|
/* Here we will do a bunch of initialization steps */
|
||||||
memory_sweep(heap_start, heap_end);
|
memory_sweep(heap_start, heap_end);
|
||||||
buddy_init(heap_start, heap_end);
|
buddy_init(heap_start, heap_end);
|
||||||
|
|
@ -62,23 +60,6 @@ void start() {
|
||||||
else
|
else
|
||||||
PANIC("Some cores seem to have been enumerated incorrectly!\n");
|
PANIC("Some cores seem to have been enumerated incorrectly!\n");
|
||||||
|
|
||||||
{
|
|
||||||
FreeList fl;
|
|
||||||
void *mem = buddy_alloc(4096);
|
|
||||||
fl_init(&fl, (uintptr_t)mem, 4096, sizeof(int));
|
|
||||||
|
|
||||||
uint32_t *hello = fl_alloc(&fl);
|
|
||||||
|
|
||||||
*hello = UINT32_MAX;
|
|
||||||
|
|
||||||
int a = fl_available(&fl);
|
|
||||||
assert_msg(fl_check(&fl) > 0, "FreeList checking failed, might be corrupt.");
|
|
||||||
kprintf("Available: %d\n", a);
|
|
||||||
kprintf("Size: %d\n", fl.size);
|
|
||||||
|
|
||||||
buddy_free(mem);
|
|
||||||
}
|
|
||||||
|
|
||||||
kprintf("To exit qemu, press CTRL+a followed by x\n");
|
kprintf("To exit qemu, press CTRL+a followed by x\n");
|
||||||
spin_unlock(&sl);
|
spin_unlock(&sl);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue