Fork me on GitHub

root/drivers/char/sysrq.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. process_list
  2. do_sysrq

   1 /*
   2  * fiwix/drivers/char/sysrq.c
   3  *
   4  * Copyright 2021, Jordi Sanfeliu. All rights reserved.
   5  * Distributed under the terms of the Fiwix License.
   6  */
   7 
   8 #include <fiwix/asm.h>
   9 #include <fiwix/sysrq.h>
  10 #include <fiwix/traps.h>
  11 #include <fiwix/stdio.h>
  12 #include <fiwix/string.h>
  13 #include <fiwix/sleep.h>
  14 #include <fiwix/sched.h>
  15 #include <fiwix/mm.h>
  16 
  17 static const char *pstate[] = {
  18         "?",
  19         "R",
  20         "S",
  21         "Z",
  22         "T",
  23         "D"
  24 };
  25 
  26 static void process_list(void)
  27 {
  28         struct proc *p;
  29 
  30         printk("USER   PID   PPID  S SLEEP_ADDR CMD\n");
  31         FOR_EACH_PROCESS(p) {
  32                 if(p->state != PROC_ZOMBIE) {
  33                         printk("%d    %5d  %5d  %s ",
  34                                 p->uid,
  35                                 p->pid,
  36                                 p->ppid,
  37                                 pstate[p->state]
  38                         );
  39                         if(p->state == PROC_SLEEPING) {
  40                                 printk("0x%08x ", p->sleep_address);
  41                         } else {
  42                                 printk("           ", p->sleep_address);
  43                         }
  44                         printk("%s\n", p->argv0);
  45                 }
  46                 p = p->next;
  47         }
  48 
  49         printk("PIDs in running queue: ");
  50         FOR_EACH_PROCESS_RUNNING(p) {
  51                 printk("%d ", p->pid);
  52                 p = p->next_run;
  53         }
  54         printk("\n");
  55 }
  56 
  57 void do_sysrq(int op)
  58 {
  59         switch(op) {
  60                 case SYSRQ_STACK:
  61                         printk("sysrq: Stack backtrace.\n");
  62                         stack_backtrace();
  63                         break;
  64                 case SYSRQ_TASKS:
  65                         printk("sysrq: Task list.\n");
  66                         process_list();
  67                         break;
  68                 case SYSRQ_UNDEF:
  69                         printk("sysrq: Undefined operation.\n");
  70                         break;
  71         }
  72 }

/* [previous][next][first][last][top][bottom][index][help] */