| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- #ifndef ZV_DISABLE_DYNAMIC
- #include <malloc.h>
- #endif
- #include "zivu_types.h"
- #include "kernel.h"
- #include "process.h"
- #ifndef ZV_DISABLE_DYNAMIC
- 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;
- }
- #else
- zv_kernel_t * zv_kernel_create() {
- return (zv_kernel_t *) NULL;
- }
- #endif
- /* 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_PROCESSES_STEP * 1;
- self->processes = (zv_process_t *) malloc(ZV_PROCESSES_STEP_SIZE * 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
|