new initrd format work, bigger keypad
parent
93396d69eb
commit
50233fff40
@ -0,0 +1,42 @@
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
extern uint8_t *initrd_start;
|
||||
extern uint32_t initrd_size;
|
||||
|
||||
char *getfile(uint32_t offset)
|
||||
{
|
||||
char *ptr = initrd_start;
|
||||
for (uint32_t i = 0; i < offset; i++) {
|
||||
uint32_t len = *((uint32_t *)ptr);
|
||||
uint32_t datalen = *((uint32_t *)(ptr + 4 + len));
|
||||
ptr += len + datalen + 8;
|
||||
if (ptr >= (char *)(initrd_start + initrd_size))
|
||||
return 0;
|
||||
}
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
char *readfile(const char *name)
|
||||
{
|
||||
char *ptr;
|
||||
for (uint32_t i = 0; ptr = getfile(i), ptr != 0; i++) {
|
||||
uint32_t len = *((uint32_t *)ptr);
|
||||
if (!strncmp(name, ptr + 4, len))
|
||||
return ptr + len + 8;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t filesize(const char *name)
|
||||
{
|
||||
char *ptr;
|
||||
for (uint32_t i = 0; ptr = getfile(i), ptr != 0; i++) {
|
||||
uint32_t len = *((uint32_t *)ptr);
|
||||
if (!strncmp(name, ptr + 4, len))
|
||||
return *((uint32_t *)ptr + len + 4);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,8 +0,0 @@
|
||||
while (1) {
|
||||
print("> ")
|
||||
input = gets()
|
||||
answer = solve(input)
|
||||
print("\n")
|
||||
print(answer)
|
||||
print("\n")
|
||||
}
|
@ -1,3 +1,8 @@
|
||||
choice = filemenu
|
||||
print("\nChoice: ")
|
||||
print(choice)
|
||||
while (1) {
|
||||
print("> ")
|
||||
input = gets()
|
||||
answer = solve(input)
|
||||
print("\n")
|
||||
print(answer)
|
||||
print("\n")
|
||||
}
|
||||
|
Loading…
Reference in New Issue