Move generic start code and memset into arch/generic.h

This commit is contained in:
2025-05-02 11:36:05 -04:00
parent ab5dd8d9fb
commit d47709b03c
7 changed files with 40 additions and 25 deletions

31
arch/generic.h Normal file
View File

@@ -0,0 +1,31 @@
/*
* This file is not meant to be included by user applications
* It contains generic arch agnostic implementations of helper functions
* and start code that can be included in <arch>.c when an architecture
* specific version is not nessisary.
*
* Copyright (c) 2025 Lucas Schumacher. All Rights Reserved.
*/
#ifndef MEMSET_DEFINED
#define MEMSET_DEFINED
// Generic memset implementation
void *memset(void* s, int c, unsigned long n) {
int8_t* mem = s;
for(long int i = 0; i < n; ++i) mem[i] = c;
return s;
}
#endif // !MEMSET_DEFINED
#ifndef _START_DEFINED
#define _START_DEFINED
// Generic _start implementation. Can't access any args
extern void exit(int8_t status);
extern int main(int argc, char** argv);
void _start() {
exit(main(0, 0));
}
void __start() {
exit(main(0, 0));
}
#endif // !_START_DEFINED