/contrib/kolibri-libc/samples/shell_io.c |
---|
4,6 → 4,7 |
int main(int argc, char**argv) |
{ |
debug_printf("%u\n", shell_get_pid()); |
char string[256]; |
shell_cls(); |
shell_printf("Number of arguments %d\n",argc); |
/contrib/kolibri-libc/source/include/shell_api.h |
---|
10,5 → 10,6 |
extern void _FUNC(shell_gets)(char *str); |
extern void _FUNC(shell_cls)(); |
extern void _FUNC(shell_exit)(); |
extern unsigned _FUNC(shell_get_pid)(); |
extern int _FUNC(shell_ping)(); |
#endif |
/contrib/kolibri-libc/source/include/stdio.h |
---|
98,6 → 98,7 |
extern int _FUNC(fscanf)(FILE *restrict, const char *restrict, ...); |
extern size_t _FUNC(fwrite)(const void *restrict, size_t size, size_t count, FILE *restrict); |
extern int _FUNC(getc)(FILE *); |
#define getc _FUNC(fgetc) |
extern int _FUNC(getchar)(void); |
extern int _FUNC(printf)(const char *restrict, ...); |
extern int _FUNC(putc)(int, FILE *); |
/contrib/kolibri-libc/source/include/stdlib.h |
---|
28,7 → 28,7 |
extern ldiv_t _FUNC(ldiv)(long, long); |
extern lldiv_t _FUNC(lldiv)(long long, long long); |
extern void _FUNC(*malloc)(size_t size); |
extern void* _FUNC(malloc)(size_t size); |
extern void* _FUNC(calloc)(size_t num, size_t size); |
extern void* _FUNC(realloc)(void *ptr, size_t newsize); |
extern void _FUNC(free)(void *ptr); |
/contrib/kolibri-libc/source/shell_api/shell.h |
---|
8,6 → 8,8 |
#define SHELL_GETC 4 |
#define SHELL_GETS 5 |
#define SHELL_CLS 6 |
#define SHELL_PID 7 |
#define SHELL_PING 8 |
#define SHELL_SHM_MAX 1024*16 |
14,7 → 16,7 |
extern char __shell_shm_name[32]; |
extern char *__shell_shm; |
extern int __shell_is_init; |
extern int __shell_init(); |
extern void __shell_init(); |
#define SHELL_WAIT() while (*__shell_shm) _ksys_delay(5) |
/contrib/kolibri-libc/source/shell_api/shell_get_pid.c |
---|
0,0 → 1,12 |
#include "shell.h" |
#include <stdlib.h> |
unsigned shell_get_pid() |
{ |
unsigned pid; |
__shell_init(); |
*__shell_shm = SHELL_PID; |
SHELL_WAIT(); |
memcpy(&pid, __shell_shm+1, sizeof(unsigned)); |
return pid; |
} |
/contrib/kolibri-libc/source/shell_api/shell_init.c |
---|
2,6 → 2,7 |
#include <string.h> |
#include <stdlib.h> |
#include "shell.h" |
#include <shell_api.h> |
char __shell_shm_name[32]; |
char*__shell_shm=NULL; |
25,14 → 26,17 |
return _ksys_shm_open(__shell_shm_name, KSYS_SHM_OPEN_ALWAYS | KSYS_SHM_WRITE, SHELL_SHM_MAX, &__shell_shm); |
} |
int __shell_init() |
void __shell_init() |
{ |
if(__shell_is_init){ |
return 0; |
} |
if(!__shell_is_init){ |
if(__shell_shm_init()){ |
debug_printf("Shell problems detected!\n"); |
return -1; |
debug_printf("SHELL problems detected!\n"); |
_ksys_exit(); |
} |
return 0; |
if(!shell_ping()){ |
debug_printf("No SHELL found!\n"); |
_ksys_exit(); |
} |
} |
} |
/contrib/kolibri-libc/source/shell_api/shell_ping.c |
---|
0,0 → 1,14 |
#include "shell.h" |
#include <stdlib.h> |
#include <ksys.h> |
int shell_ping() |
{ |
__shell_init(); |
*__shell_shm = SHELL_PING; |
_ksys_delay(10); |
if(*__shell_shm==SHELL_OK){ |
return 1; |
} |
return 0; |
} |