Skip to content

Commit

Permalink
Restructure the repository.
Browse files Browse the repository at this point in the history
.
  • Loading branch information
HAKarlsson committed Oct 23, 2024
1 parent e97d0c6 commit f0d4f1b
Show file tree
Hide file tree
Showing 93 changed files with 2,234 additions and 2,702 deletions.
24 changes: 0 additions & 24 deletions Makefile

This file was deleted.

11 changes: 0 additions & 11 deletions common/inc/plat/qemu_virt.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,3 @@

/// Stack size of 1024 KiB
#define S3K_LOG_STACK_SIZE 10

#define INIT_CAPS \
{ \
[0] = cap_mk_pmp(0x20005fff, MEM_RWX), \
[1] = cap_mk_memory(0x80020000, 0x88000000, MEM_RWX), \
[2] = cap_mk_memory(0x10000000, 0x10001000, MEM_RW), \
[3] = cap_mk_memory(0x200b000, 0x200c000, MEM_R), \
[4] = cap_mk_time(0, 0, S3K_SLOT_CNT), \
[8] = cap_mk_monitor(0, S3K_PROC_CNT), \
[9] = cap_mk_channel(0, S3K_CHAN_CNT), \
}
23 changes: 0 additions & 23 deletions common/src/altc/gets.c

This file was deleted.

131 changes: 18 additions & 113 deletions common/src/altc/printf.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,116 +3,21 @@
#include <stdarg.h>
#include <stddef.h>

#define ALT_PRINTF_BUF_SIZE 128

static char *write_dec(char *restrict dst, const char *end,
unsigned long long val)
{
if (!val && dst != end) {
*(dst++) = '0';
} else if (dst != end) {
int i = 0;
char buf[24];
while (val) {
int tmp = val % 10;
buf[i++] = '0' + tmp;
val /= 10;
}
while (i > 0 && dst != end)
*(dst++) = buf[--i];
}
return dst;
}

static char *write_hex(char *restrict dst, const char *end,
unsigned long long val)
{
if (!val && dst != end) {
*(dst++) = '0';
} else if (dst != end) {
int i = 0;
char buf[16];
while (val) {
int tmp = val & 0xF;
buf[i++] = tmp < 10 ? ('0' + tmp) : 'A' + (tmp - 10);
val >>= 4;
}
while (i > 0 && dst != end)
*(dst++) = buf[--i];
}
return dst;
}

static char *write_str(char *restrict dst, const char *end, char *restrict src)
{
while (dst != end && *src != '\0')
*(dst++) = *(src++);
return dst;
}

static char *write_char(char *restrict dst, const char *end, char c)
{
if (dst != end)
*(dst++) = c;
return dst;
}

int alt_vsnprintf(char *restrict str, size_t size, const char *restrict fmt,
va_list ap)
{
char *s = str;
const char *end = str + size - 1;
while (*fmt != '\0' && s != end) {
if (*(fmt++) != '%') {
s = write_char(s, end, *(fmt - 1));
continue;
}
switch (*(fmt++)) {
case '%':
s = write_char(s, end, '%');
break;
case 'c':
s = write_char(s, end, va_arg(ap, int));
break;
case 's':
s = write_str(s, end, va_arg(ap, char *));
break;
case 'x':
s = write_hex(s, end, va_arg(ap, unsigned int));
break;
case 'X':
s = write_hex(s, end, va_arg(ap, unsigned long));
break;
case 'd':
s = write_dec(s, end, va_arg(ap, unsigned int));
break;
case 'D':
s = write_dec(s, end, va_arg(ap, unsigned long));
break;
case '\0':
break;
}
}
*s = '\0';
return s - str;
}

int alt_snprintf(char *restrict str, size_t size, const char *restrict fmt, ...)
{
va_list ap;
va_start(ap, fmt);
int len = alt_vsnprintf(str, size, fmt, ap);
va_end(ap);
return len;
}

int alt_printf(const char *restrict fmt, ...)
{
char buf[ALT_PRINTF_BUF_SIZE];
va_list ap;
va_start(ap, fmt);
int len = alt_vsnprintf(buf, ALT_PRINTF_BUF_SIZE, fmt, ap);
va_end(ap);
alt_putstr(buf);
return len;
}
int alt_fputchar(FILE *f, char c);
int alt_fputuint(FILE *f, unsigned long long val);
int alt_fputhex(FILE *f, unsigned long long val);
int alt_fputstr(FILE *f, const char *s);
int alt_vfprintf(FILE *f, const char *fmt, va_list ap);
int alt_fprintf(FILE *f, const char *fmt, ...)

int alt_putchar(char c);
int alt_putstr(const char *s);
int alt_putuint(unsigned long long val);
int alt_puthex(unsigned long long val);
int alt_vprintf(const char *fmt, va_list ap);
int alt_printf(const char *fmt, ...);

int alt_snputuint(char *buf, int size, unsigned long long val);
int alt_snputhex(char *buf, int size, unsigned long long val);
int alt_snvprintf(char *buf, int size, const char *fmt, va_list ap);
int alt_snprintf(char *buf, int size, const char *fmt, ...);
29 changes: 0 additions & 29 deletions common/src/altc/puts.c

This file was deleted.

91 changes: 0 additions & 91 deletions kernel/Makefile

This file was deleted.

18 changes: 0 additions & 18 deletions kernel/inc/cap_ipc.h

This file was deleted.

5 changes: 0 additions & 5 deletions kernel/inc/cap_lock.h

This file was deleted.

Loading

0 comments on commit f0d4f1b

Please sign in to comment.