123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- /* Copyright (C) 2020 Jeremiah Orians
- * This file is part of M2-Planet.
- *
- * M2-Planet is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * M2-Planet is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with M2-Planet. If not, see <http://www.gnu.org/licenses/>.
- */
- #define NULL 0
- #define __PATH_MAX 4096
- #define EOF 0xFFFFFFFF
- void* malloc(unsigned size);
- int access(char* pathname, int mode)
- {
- /* Completely meaningless in bare metal */
- return 0;
- }
- int chdir(char* path)
- {
- /* Completely meaningless in bare metal */
- return 0;
- }
- int fchdir(int fd)
- {
- /* Completely meaningless in bare metal */
- return 0;
- }
- void _exit(int value)
- {
- }
- int fork()
- {
- /* Completely meaningless in bare metal */
- return 0;
- }
- int waitpid (int pid, int* status_ptr, int options)
- {
- /* Completely meaningless in bare metal */
- return 0;
- }
- int execve(char* file_name, char** argv, char** envp)
- {
- /* Completely meaningless in bare metal */
- return 0;
- }
- int __read(int fd)
- {
- asm("LOAD R1 R14 0"
- "FGETC");
- }
- int read(int fd, char* buf, unsigned count)
- {
- unsigned i = 0;
- int c;
- while(i < count)
- {
- c = __read(fd);
- if(EOF == c) break;
- buf[i] = c;
- i = i + 1;
- }
- return i;
- }
- void __write(char s, int fd)
- {
- asm("LOAD R0 R14 0"
- "LOAD R1 R14 4"
- "FPUTC");
- }
- int write(int fd, char* buf, unsigned count)
- {
- unsigned i = 0;
- while(i < count)
- {
- __write(buf[i], fd);
- i = i + 1;
- }
- }
- int lseek(int fd, int offset, int whence)
- {
- asm("LOAD R0 R14 0"
- "LOAD R1 R14 4"
- "LOAD R2 R14 8"
- "FSEEK");
- }
- int close(int fd)
- {
- asm("LOAD R0 R14 0"
- "FCLOSE");
- }
- int _getcwd(char* buf, int size)
- {
- /* Completely meaningless in bare metal */
- return 0;
- }
- char* getcwd(char* buf, unsigned size)
- {
- /* Completely meaningless in bare metal */
- return 0;
- }
- char* getwd(char* buf)
- {
- /* Completely meaningless in bare metal */
- return 0;
- }
- char* get_current_dir_name()
- {
- /* Completely meaningless in bare metal */
- return 0;
- }
- /********************************************************************************
- * We are running on bare metal. Just don't go past the end of install RAM *
- ********************************************************************************/
- int brk(void *addr)
- {
- asm("LOAD R0 R14 0"
- "ADDU R0 R12 R0"
- "SWAP R0 R12");
- }
- int chmod(char *pathname, int mode)
- {
- /* Completely meaningless in bare metal */
- return 0;
- }
- struct utsname
- {
- char sysname[65]; /* Operating system name (e.g., "Linux") */
- char nodename[65]; /* Name within "some implementation-defined network" */
- char release[65]; /* Operating system release (e.g., "2.6.28") */
- char version[65]; /* Operating system version */
- char machine[65]; /* Hardware identifier */
- };
- int uname(struct utsname* unameData)
- {
- /* Completely meaningless in bare metal */
- return 0;
- }
|