| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- #ifndef ZV_DISABLE_DYNAMIC
- #include <malloc.h>
- #endif
- #include "zivu_types.h"
- #include "kernel.h"
- #include "process.h"
- zv_kernel_t * zv_kernel_create();
- zv_kernel_t * zv_kernel_create() {
- zv_kernel_t *self = (zv_kernel_t *) malloc(sizeof(zv_kernel_t));
-
- if (self != NULL) {
- zv_kernel_init(self, NULL, 0x00);
- }
- return self;
- }
- /* For dynamic also kernel. */
- #ifndef ZV_DISABLE_DYNAMIC
- void zv_kernel_init(
- zv_kernel_t *self,
- zv_process_t *container,
- zv_pid_t processes_count
- ) {
- self->current_process = ZV_IDLE_PROCESS;
- if (container != NULL) {
- self->processes = container;
- self->processes_count = processes_count;
- self->is_dynamic = false;
-
- return;
- }
- self->processes_count = ZV_DYNAMIC_PROCESSES_STEP * 1;
- self->processes = (zv_process_t *) malloc(ZV_DYNAMIC_PROCESSES_STEP * 1);
- self->is_dynamic = true;
- /* When cannot alloc, make kernel unuseable. */
- if (self->processes == NULL) {
- self->processes_count = 0x00;
- self->is_dynamic = false;
- }
- }
- #else
- void zv_kernel_init(
- zv_kernel_t *self,
- zv_process_t *container,
- zv_pid_t processes_count
- ) {
- self->current_process = ZV_IDLE_PROCESS;
- self->processes = container;
- self->processes_count = processes_count;
- }
- #endif
|