Main Page | Directories | File List | Globals

agnix_console.c File Reference

#include <agnix/agnix.h>
#include <agnix/adi/adi.h>
#include <agnix/net/net.h>
#include <agnix/terminal.h>
#include <agnix/threads.h>
#include <agnix/sprintf.h>
#include <agnix/memory.h>
#include <agnix/machine.h>
#include <agnix/sched.h>
#include <agnix/console.h>
#include <agnix/strings.h>
#include <agnix/unistd.h>
#include <agnix/agnix_console.h>

Include dependency graph for agnix_console.c:

Go to the source code of this file.

Defines

#define MOD_NAME   "CONSOLE: "

Functions

agnix_console_menu_s * agnix_console_print_help_name (struct agnix_console_menu_s *menu, struct agnix_console_command_s *command)
agnix_console_menu_s * agnix_console_print_help (struct agnix_console_menu_s *menu, struct agnix_console_command_s *command, char *buf)
agnix_console_menu_s * agnix_console_next_node (struct agnix_console_menu_s *menu, struct agnix_console_command_s *command, char *buf)
agnix_console_menu_s * agnix_console_prev_node (struct agnix_console_menu_s *menu, struct agnix_console_command_s *command, char *buf)
agnix_console_menu_s * agnix_console_ip_stats (struct agnix_console_menu_s *menu, struct agnix_console_command_s *command, char *buf)
agnix_console_menu_s * agnix_console_ip_debug (struct agnix_console_menu_s *menu, struct agnix_console_command_s *command, char *buf)
agnix_console_menu_s * agnix_console_arp_stats (struct agnix_console_menu_s *menu, struct agnix_console_command_s *command, char *buf)
agnix_console_menu_s * agnix_console_arp_request (struct agnix_console_menu_s *menu, struct agnix_console_command_s *command, char *buf)
agnix_console_menu_s * agnix_console_pci_list (struct agnix_console_menu_s *menu, struct agnix_console_command_s *command, char *buf)
agnix_console_menu_s * agnix_console_print_memory (struct agnix_console_menu_s *menu, struct agnix_console_command_s *command, char *buf)
agnix_console_menu_s * agnix_console_print_cpuinfo (struct agnix_console_menu_s *menu, struct agnix_console_command_s *command, char *buf)
agnix_console_menu_s * agnix_console_halt (struct agnix_console_menu_s *menu, struct agnix_console_command_s *command, char *buf)
agnix_console_menu_s * agnix_console_powerdown (struct agnix_console_menu_s *menu, struct agnix_console_command_s *command, char *buf)
agnix_console_menu_s * agnix_console_reboot (struct agnix_console_menu_s *menu, struct agnix_console_command_s *command, char *buf)
agnix_console_menu_s * agnix_console_ps (struct agnix_console_menu_s *menu, struct agnix_console_command_s *command, char *buf)
agnix_console_menu_s * agnix_console_net_ifconfig (struct agnix_console_menu_s *menu, struct agnix_console_command_s *command, char *buf)
agnix_console_menu_s * agnix_console_vm_stats (struct agnix_console_menu_s *menu, struct agnix_console_command_s *command, char *buf)
agnix_console_menu_s * agnix_console_vm_free (struct agnix_console_menu_s *menu, struct agnix_console_command_s *command, char *buf)
agnix_console_menu_s * agnix_console_command_exec (struct agnix_console_menu_s *menu, char *buf)
void agnix_console_main (void)
void agnix_console_thread (void *data)
int agnix_console_start (void)

Variables

adi_netdev_s rtl_8029_netdev
agnix_console_menu_s console_main_menu = { "main", console_main_commands, NULL }
agnix_console_menu_s console_net_menu = { "net", console_net_commands, &console_main_menu }
agnix_console_menu_s console_ip_menu = { "ip", console_ip_commands, &console_net_menu }
agnix_console_menu_s console_arp_menu = { "arp", console_arp_commands, &console_net_menu }
agnix_console_menu_s console_adi_menu = { "adi", console_adi_commands, &console_main_menu }
agnix_console_menu_s console_pci_menu = { "pci", console_pci_commands, &console_adi_menu }
agnix_console_menu_s console_arch_menu = { "arch", console_arch_commands, &console_main_menu }
agnix_console_menu_s console_vm_menu = { "vm", console_vm_commands, &console_main_menu }
agnix_console_command_s console_ip_commands []
agnix_console_command_s console_arp_commands []
agnix_console_command_s console_net_commands []
agnix_console_command_s console_adi_commands []
agnix_console_command_s console_pci_commands []
agnix_console_command_s console_arch_commands []
agnix_console_command_s console_vm_commands []
agnix_console_command_s console_main_commands []
terminal_s term_sys [MAX_TERMINALS]
int term_cur


Define Documentation

#define MOD_NAME   "CONSOLE: "
 

Definition at line 28 of file agnix_console.c.


Function Documentation

struct agnix_console_menu_s* agnix_console_arp_request struct agnix_console_menu_s *  menu,
struct agnix_console_command_s *  command,
char *  buf
 

Definition at line 88 of file agnix_console.c.

References arp_resolve(), memset(), net_addr(), printf(), and rtl_8029_netdev.

00089 {
00090     struct arp_neigh_s neigh;
00091     char *req_addr;
00092 
00093     req_addr = buf;
00094 
00095     if (req_addr == NULL) {
00096         printf("\nYou must specify IP address for ARP request\n");
00097         printf("Usage: request [IP]\n");
00098         return NULL;
00099     }
00100 
00101     if (net_addr(req_addr, &neigh.addr) < 0) {
00102         printf("\nInvalid format of interface address\n");
00103         return NULL;
00104     }
00105 
00106     neigh.addr.address_len = 4;
00107     memset(neigh.mac, 0, ETH_ALEN);
00108 
00109     printf("\nWho-has %d.%d.%d.%d\n", 
00110     neigh.addr.address[0], neigh.addr.address[1], neigh.addr.address[2], neigh.addr.address[3]);
00111 
00112     if (arp_resolve(&rtl_8029_netdev, &neigh) < 0) {
00113         printf("%d.%d.%d.%d unreachable\n", 
00114         neigh.addr.address[0], neigh.addr.address[1], neigh.addr.address[2], neigh.addr.address[3]);
00115     } else {
00116         printf("%d.%d.%d.%d is-at %02x:%02x:%02x:%02x:%02x:%02x\n",
00117         neigh.addr.address[0], neigh.addr.address[1], neigh.addr.address[2], neigh.addr.address[3],
00118         neigh.mac[0], neigh.mac[1], neigh.mac[2], neigh.mac[3], neigh.mac[4], neigh.mac[5]);
00119     }
00120     
00121     return NULL;
00122 }

Here is the call graph for this function:

struct agnix_console_menu_s* agnix_console_arp_stats struct agnix_console_menu_s *  menu,
struct agnix_console_command_s *  command,
char *  buf
 

Definition at line 82 of file agnix_console.c.

References arp_print_stats().

00083 {
00084     arp_print_stats();    
00085     return NULL;
00086 }

Here is the call graph for this function:

struct agnix_console_menu_s* agnix_console_command_exec struct agnix_console_menu_s *  menu,
char *  buf
 

Definition at line 217 of file agnix_console.c.

References printf(), word_cmp(), and word_next().

Referenced by agnix_console_main().

00218 {
00219     struct agnix_console_command_s *command = menu->commands;
00220     struct agnix_console_menu_s *next_menu;
00221     char *ptr;
00222     int i;
00223 
00224     for (i = 0; i < COMMAND_MAX_ENTRIES; i++) {
00225         if (command[i].name == NULL)
00226             break;
00227         
00228         if (!word_cmp(command[i].name, buf, COMMAND_MAX_NAME_LEN)) {
00229 
00230             ptr = word_next(buf, COMMAND_MAX_NAME_LEN);
00231             if (command[i].action != NULL) {
00232                 if ((next_menu = command[i].action(menu, &command[i], ptr)) == NULL)
00233                     return menu;
00234                 else
00235                     return next_menu;
00236                 } else {
00237                     printf("Command action is NULL\n");
00238                     return menu;
00239                 }
00240         }
00241     }
00242 
00243     printf("Unknown command, try 'help'\n");
00244     
00245     return menu;
00246 }

Here is the call graph for this function:

struct agnix_console_menu_s* agnix_console_halt struct agnix_console_menu_s *  menu,
struct agnix_console_command_s *  command,
char *  buf
 

Definition at line 142 of file agnix_console.c.

References do_machine_halt().

00143 {
00144     do_machine_halt();
00145     return NULL;
00146 }

Here is the call graph for this function:

struct agnix_console_menu_s* agnix_console_ip_debug struct agnix_console_menu_s *  menu,
struct agnix_console_command_s *  command,
char *  buf
 

Definition at line 72 of file agnix_console.c.

References ip_ioctl_get_debug(), and ip_ioctl_set_debug().

00073 {
00074     int debug;
00075     
00076     debug = ip_ioctl_get_debug() ^ 1; 
00077     ip_ioctl_set_debug(debug);
00078     
00079     return NULL;
00080 }

Here is the call graph for this function:

struct agnix_console_menu_s* agnix_console_ip_stats struct agnix_console_menu_s *  menu,
struct agnix_console_command_s *  command,
char *  buf
 

Definition at line 66 of file agnix_console.c.

References ip_print_stats().

00067 {
00068     ip_print_stats();    
00069     return NULL;
00070 }

Here is the call graph for this function:

void agnix_console_main void   ) 
 

Definition at line 338 of file agnix_console.c.

References agnix_console_command_exec(), buf, console_main_menu, memset(), and printf().

Referenced by agnix_console_thread().

00339 {
00340     struct agnix_console_menu_s *cur_menu = &console_main_menu;
00341     char buf[COMMAND_MAX_LEN + 1];
00342     int ret;
00343 
00344     for (;;) {
00345 
00346         printf("agnix %s> ", cur_menu->name); 
00347 
00348         memset(buf, 0, COMMAND_MAX_LEN + 1);
00349         if ((ret = read(0, buf, COMMAND_MAX_LEN)) > 0) {
00350             cur_menu = agnix_console_command_exec(cur_menu, buf);
00351             printf("\n");
00352         }
00353     }
00354 }

Here is the call graph for this function:

struct agnix_console_menu_s* agnix_console_net_ifconfig struct agnix_console_menu_s *  menu,
struct agnix_console_command_s *  command,
char *  buf
 

Definition at line 166 of file agnix_console.c.

References adi_netdev_find_by_name(), adi_netdev_print_interfaces(), ip_ioctl_set_ifaddr(), net_addr(), printf(), and word_next().

00167 {
00168     struct net_addr_s addr;
00169     struct adi_netdev_s *netdev;
00170     char *if_name;
00171     char *if_addr;
00172 
00173     if_name = buf;
00174     if_addr = word_next(buf, COMMAND_MAX_NAME_LEN);
00175 
00176     if ((if_name != NULL) && (if_addr == NULL)) {
00177         printf("\nYou must specify IP address for interface\n");
00178         printf("Usage: ifconfig [ifname addr]\n");
00179         return NULL;
00180     }
00181 
00182     if (if_name != NULL) {
00183         if ((netdev = adi_netdev_find_by_name(if_name)) == NULL) {
00184             printf("\n%s interface not found\n", if_name);
00185             return NULL;
00186         } 
00187     
00188         if (net_addr(if_addr, &addr) < 0) {
00189             printf("\nInvalid format of interface address\n");
00190             return NULL;
00191         }
00192 
00193         printf("\nSetting %s IP to %d.%d.%d.%d\n", netdev->if_name,
00194         addr.address[0], addr.address[1], addr.address[2], addr.address[3]);
00195         addr.address_len = 4;
00196         
00197         ip_ioctl_set_ifaddr(netdev, &addr);
00198     } else {
00199         adi_netdev_print_interfaces();
00200     }
00201      
00202     return NULL;
00203 }

Here is the call graph for this function:

struct agnix_console_menu_s* agnix_console_next_node struct agnix_console_menu_s *  menu,
struct agnix_console_command_s *  command,
char *  buf
 

Definition at line 56 of file agnix_console.c.

00057 {
00058     return command->submenu;
00059 }

struct agnix_console_menu_s* agnix_console_pci_list struct agnix_console_menu_s *  menu,
struct agnix_console_command_s *  command,
char *  buf
 

Definition at line 124 of file agnix_console.c.

References pcibus_print_all().

00125 {
00126     pcibus_print_all();    
00127     return NULL;
00128 }

Here is the call graph for this function:

struct agnix_console_menu_s* agnix_console_powerdown struct agnix_console_menu_s *  menu,
struct agnix_console_command_s *  command,
char *  buf
 

Definition at line 148 of file agnix_console.c.

References do_machine_powerdown().

00149 {
00150     do_machine_powerdown();
00151     return NULL;
00152 }

Here is the call graph for this function:

struct agnix_console_menu_s* agnix_console_prev_node struct agnix_console_menu_s *  menu,
struct agnix_console_command_s *  command,
char *  buf
 

Definition at line 61 of file agnix_console.c.

00062 {
00063     return menu->parent;
00064 }

struct agnix_console_menu_s* agnix_console_print_cpuinfo struct agnix_console_menu_s *  menu,
struct agnix_console_command_s *  command,
char *  buf
 

Definition at line 136 of file agnix_console.c.

References cpu_print_cpuinfo().

00137 {
00138     cpu_print_cpuinfo();
00139     return NULL;
00140 }

Here is the call graph for this function:

struct agnix_console_menu_s* agnix_console_print_help struct agnix_console_menu_s *  menu,
struct agnix_console_command_s *  command,
char *  buf
 

Definition at line 51 of file agnix_console.c.

References agnix_console_print_help_name().

00052 {
00053     return agnix_console_print_help_name(menu, command);
00054 }

Here is the call graph for this function:

struct agnix_console_menu_s* agnix_console_print_help_name struct agnix_console_menu_s *  menu,
struct agnix_console_command_s *  command
 

Definition at line 32 of file agnix_console.c.

References printf(), and strlen().

Referenced by agnix_console_print_help().

00033 {
00034     struct agnix_console_command_s *commands = menu->commands;
00035     int i, j;
00036 
00037     for (i = 0; i < COMMAND_MAX_ENTRIES; i++) {
00038         if (commands[i].name == NULL)
00039             break;
00040         
00041         printf("%s", commands[i].name);
00042         for (j = strlen(commands[i].name); j < 10; j++)
00043             printf(" ");
00044         
00045         printf(" - %s\n", commands[i].desc);
00046     }
00047     
00048     return NULL;
00049 }

Here is the call graph for this function:

struct agnix_console_menu_s* agnix_console_print_memory struct agnix_console_menu_s *  menu,
struct agnix_console_command_s *  command,
char *  buf
 

Definition at line 130 of file agnix_console.c.

References bootmem_print_memory().

00131 {
00132     bootmem_print_memory();    
00133     return NULL;
00134 }

Here is the call graph for this function:

struct agnix_console_menu_s* agnix_console_ps struct agnix_console_menu_s *  menu,
struct agnix_console_command_s *  command,
char *  buf
 

Definition at line 160 of file agnix_console.c.

References scheduler_print_tasks().

00161 {
00162     scheduler_print_tasks();
00163     return NULL;
00164 }

Here is the call graph for this function:

struct agnix_console_menu_s* agnix_console_reboot struct agnix_console_menu_s *  menu,
struct agnix_console_command_s *  command,
char *  buf
 

Definition at line 154 of file agnix_console.c.

References do_machine_reboot().

00155 {
00156     do_machine_reboot();
00157     return NULL;
00158 }

Here is the call graph for this function:

int agnix_console_start void   ) 
 

Definition at line 374 of file agnix_console.c.

References agnix_console_thread(), and create_kernel_thread().

Referenced by start_kernel().

00375 {
00376     int i;
00377     
00378     for (i = 0; i < MAX_TERMINALS; i++) {    
00379         create_kernel_thread("console", agnix_console_thread, (void *)i);
00380     }
00381     
00382     return 0;
00383 }

Here is the call graph for this function:

void agnix_console_thread void *  data  ) 
 

Definition at line 356 of file agnix_console.c.

References agnix_console_main(), MOD_NAME, printf(), and sprintf().

Referenced by agnix_console_start().

00357 {
00358     char console_name[10];
00359     int console_nr;
00360 
00361     console_nr = (int)data;
00362 
00363     sprintf(console_name, "tty%d", console_nr);
00364     if ((open(console_name, 0, 0)) < 0) {
00365         printf("can not open terminal\n");
00366         for(;;);
00367     }
00368 
00369     printf(MOD_NAME "Agnix Console %s starting ... ok\n\n", console_name, console_nr);
00370 
00371     agnix_console_main();
00372 }

Here is the call graph for this function:

struct agnix_console_menu_s* agnix_console_vm_free struct agnix_console_menu_s *  menu,
struct agnix_console_command_s *  command,
char *  buf
 

Definition at line 211 of file agnix_console.c.

References buddy_alloc_print_free().

00212 {
00213     buddy_alloc_print_free();
00214     return NULL;
00215 }

Here is the call graph for this function:

struct agnix_console_menu_s* agnix_console_vm_stats struct agnix_console_menu_s *  menu,
struct agnix_console_command_s *  command,
char *  buf
 

Definition at line 205 of file agnix_console.c.

References buddy_alloc_print_stats().

00206 {
00207     buddy_alloc_print_stats();
00208     return NULL;
00209 }

Here is the call graph for this function:


Variable Documentation

struct agnix_console_command_s console_adi_commands[]
 

Initial value:

 {
    { "help",   "Print this help",       agnix_console_print_help, &console_adi_menu, NULL },
    { "pci",    "PCI Bus module",        agnix_console_next_node,  &console_adi_menu, &console_pci_menu  },
    { "return", "Return to parent menu", agnix_console_prev_node,  &console_adi_menu, NULL },
    { NULL }
}

Definition at line 282 of file agnix_console.c.

struct agnix_console_menu_s console_adi_menu = { "adi", console_adi_commands, &console_main_menu }
 

Definition at line 327 of file agnix_console.c.

struct agnix_console_command_s console_arch_commands[]
 

Initial value:

 {
    { "cpuinfo", "Print cpu info",        agnix_console_print_cpuinfo, &console_adi_menu, NULL },
    { "help",    "Print this help",       agnix_console_print_help,    &console_adi_menu, NULL },
    { "memmap",  "Print memory map",      agnix_console_print_memory,  &console_adi_menu, NULL },
    { "return",  "Return to parent menu", agnix_console_prev_node,     &console_adi_menu, NULL },
    { NULL }
}

Definition at line 296 of file agnix_console.c.

struct agnix_console_menu_s console_arch_menu = { "arch", console_arch_commands, &console_main_menu }
 

Definition at line 332 of file agnix_console.c.

struct agnix_console_command_s console_arp_commands[]
 

Initial value:

 {
    { "help",   "Print this help",            agnix_console_print_help, &console_arp_menu, NULL },
    { "return", "Return to parent menu",      agnix_console_prev_node,  &console_arp_menu, NULL },
    { "request","Send ARP Request",           agnix_console_arp_request,  &console_arp_menu, NULL },
    { "stats",  "Statistics of ARP protocol", agnix_console_arp_stats,  &console_arp_menu, NULL },
    { NULL }
}

Definition at line 265 of file agnix_console.c.

struct agnix_console_menu_s console_arp_menu = { "arp", console_arp_commands, &console_net_menu }
 

Definition at line 331 of file agnix_console.c.

struct agnix_console_command_s console_ip_commands[]
 

Initial value:

 {
    { "help",   "Print this help",              agnix_console_print_help, &console_ip_menu, NULL },
    { "return", "Return to parent menu",        agnix_console_prev_node,  &console_ip_menu, NULL },
    { "stats",  "Statistics of IP protocol",    agnix_console_ip_stats,   &console_ip_menu, NULL },
    { "debug",  "Enable/disable packets debug", agnix_console_ip_debug,   &console_ip_menu, NULL },
    { NULL }
}

Definition at line 257 of file agnix_console.c.

struct agnix_console_menu_s console_ip_menu = { "ip", console_ip_commands, &console_net_menu }
 

Definition at line 330 of file agnix_console.c.

struct agnix_console_command_s console_main_commands[]
 

Initial value:

 {
    { "adi",       "Driver Interface Subsystem",   agnix_console_next_node,  &console_main_menu,  &console_adi_menu },
    { "arch",      "Architecture dependent subsystem",
                                                   agnix_console_next_node,  &console_main_menu,  &console_arch_menu },
    { "halt",      "Halt machine",                 agnix_console_halt,       &console_main_menu,  NULL },
    { "help",      "Print this help",              agnix_console_print_help, &console_main_menu,  NULL },
    { "net",       "Network subsystem",            agnix_console_next_node,  &console_main_menu,  &console_net_menu },
    { "powerdown", "Powerdown machine",            agnix_console_powerdown,  &console_main_menu,  NULL },
    { "ps",        "Task list",                    agnix_console_ps,         &console_main_menu,  NULL },
    { "reboot",    "Reboot machine",               agnix_console_reboot,     &console_main_menu,  NULL },
    { "vm",        "Virtual memory subsystem",     agnix_console_next_node,  &console_main_menu,  &console_vm_menu },
    { NULL }
}

Definition at line 312 of file agnix_console.c.

struct agnix_console_menu_s console_main_menu = { "main", console_main_commands, NULL }
 

Definition at line 326 of file agnix_console.c.

Referenced by agnix_console_main().

struct agnix_console_command_s console_net_commands[]
 

Initial value:

 {
    { "help",   "Print this help",       agnix_console_print_help, &console_net_menu, NULL },
    { "ip",     "IP protocol module",    agnix_console_next_node,  &console_net_menu, &console_ip_menu  },
    { "arp",    "ARP protocol module",   agnix_console_next_node,  &console_net_menu, &console_arp_menu  },
    { "ifconfig", "ifconfig emulator",   agnix_console_net_ifconfig, &console_net_menu, NULL  },
    { "return", "Return to parent menu", agnix_console_prev_node,  &console_net_menu, NULL },
    { NULL }
}

Definition at line 273 of file agnix_console.c.

struct agnix_console_menu_s console_net_menu = { "net", console_net_commands, &console_main_menu }
 

Definition at line 329 of file agnix_console.c.

struct agnix_console_command_s console_pci_commands[]
 

Initial value:

 {
    { "help",   "Print this help",            agnix_console_print_help, &console_pci_menu, NULL },
    { "return", "Return to parent menu",      agnix_console_prev_node,  &console_pci_menu, NULL },
    { "list",   "List all PCI devices",       agnix_console_pci_list,   &console_pci_menu, NULL },
    { NULL }
}

Definition at line 289 of file agnix_console.c.

struct agnix_console_menu_s console_pci_menu = { "pci", console_pci_commands, &console_adi_menu }
 

Definition at line 328 of file agnix_console.c.

struct agnix_console_command_s console_vm_commands[]
 

Initial value:

 {
    { "free",     "VM free",               agnix_console_vm_free,    &console_vm_menu, NULL  },
    { "help",     "Print this help",       agnix_console_print_help, &console_vm_menu, NULL },
    { "stats",    "VM statistics",         agnix_console_vm_stats,   &console_vm_menu, NULL  },
    { "return",   "Return to parent menu", agnix_console_prev_node,  &console_vm_menu, NULL },
    { NULL }
}

Definition at line 304 of file agnix_console.c.

struct agnix_console_menu_s console_vm_menu = { "vm", console_vm_commands, &console_main_menu }
 

Definition at line 333 of file agnix_console.c.

struct adi_netdev_s rtl_8029_netdev
 

Initial value:

 {
    .if_ops             = &rtl_8029_netdev_ops,
}

Definition at line 445 of file rtl_8029.c.

Referenced by agnix_console_arp_request(), rtl_8029_irq(), rtl_8029_probe(), and rtl_8029_send_frame().

int term_cur
 

Definition at line 29 of file syscons.c.

Referenced by adi_sysconsole_init(), kbd_irq_handler(), kbd_screen_down(), kbd_screen_up(), syscons_read_current(), and terminal_switch().

struct terminal_s term_sys[MAX_TERMINALS]
 

Definition at line 31 of file syscons.c.

Referenced by adi_sysconsole_init(), kbd_irq_handler(), kbd_screen_down(), kbd_screen_up(), syscons_open(), syscons_read_current(), terminal_open(), and terminal_switch().

Dokumentacje wygenerowano programem Doxygen 1.4.2 dla projektu Agnix