ppos

Usermode educational operating system.
Log | Files | Refs

ppos.c (1451B)


      1 // PingPongOS - PingPong Operating System
      2 // © Prof. Carlos A. Maziero, DINF UFPR
      3 // Versão 2.1 -- 06/2026
      4 
      5 // ATENÇÃO: ESTE ARQUIVO NÃO DEVE SER ALTERADO;
      6 // ALTERAÇÕES SERÃO DESCARTADAS NA CORREÇÃO.
      7 
      8 // Funções iniciais do PPOS
      9 
     10 #include "hardware/cpu.h"
     11 #include "lib/pplibc.h"
     12 #include "ppos.h"
     13 
     14 //----------------------------------------------------------------------
     15 
     16 // Inicia o sistema operacional
     17 static void ppos_init()
     18 {
     19     printk("PPOS: system initializing\n");
     20 
     21     // inicia os subsistemas
     22     mem_init();
     23     task_init();
     24     dispatcher_init();
     25     sched_init();
     26     time_init();
     27     sem_init();
     28     mqueue_init();
     29     block_init("hardware/disk.dat");
     30 
     31     printk("PPOS: system ready (uptime %u ms)\n", time());
     32 }
     33 
     34 //----------------------------------------------------------------------
     35 
     36 // Encerra o sistema operacional
     37 void ppos_term()
     38 {
     39     printk("PPOS: system terminating\n", time());
     40 
     41     // encerra os subsistemas (em ordem contrária ao ppos_init)
     42     block_term("hardware/disk.dat");
     43     mqueue_term();
     44     sem_term();
     45     time_term();
     46     sched_term();
     47     dispatcher_term();
     48     task_term();
     49     mem_term();
     50 
     51     printk("PPOS: system terminated (uptime %u ms)\n", time());
     52 }
     53 
     54 //----------------------------------------------------------------------
     55 
     56 int main()
     57 {
     58     ppos_init();
     59     dispatcher();
     60     ppos_term();
     61     hw_poweroff(0);
     62 }
     63 
     64 //----------------------------------------------------------------------