Merge commit 'hdt-erwan/master' into for-erwan
authorPierre-Alexandre Meyer <pierre@mouraf.org>
Sat, 11 Apr 2009 01:49:24 +0000 (18:49 -0700)
committerPierre-Alexandre Meyer <pierre@mouraf.org>
Sat, 11 Apr 2009 01:49:24 +0000 (18:49 -0700)
Conflicts:

com32/hdt/hdt-ata.c
com32/hdt/hdt-cli-pxe.c
com32/hdt/hdt-cli-vesa.c
com32/hdt/hdt-cli.c
com32/hdt/hdt-common.c
com32/hdt/hdt-menu-pci.c

1  2 
com32/hdt/hdt-ata.c
com32/hdt/hdt-cli-pxe.c
com32/hdt/hdt-cli-vesa.c
com32/hdt/hdt-cli.c
com32/hdt/hdt-common.c
com32/hdt/hdt-common.h

Simple merge
  #include "hdt-cli.h"
  #include "hdt-common.h"
  
 -void main_show_pxe(struct s_hardware *hardware)
 +void main_show_pxe(int argc __unused, char **argv __unused,
 +                 struct s_hardware *hardware)
  {
 -  char buffer[81];
 -  memset(buffer, 0, sizeof(81));
 -  if (hardware->sv->filesystem != SYSLINUX_FS_PXELINUX) {
 -    more_printf("You are not currently using PXELINUX\n");
 -    return;
 -  }
 +      char buffer[81];
 +      memset(buffer, 0, sizeof(81));
 +      if (hardware->sv->filesystem != SYSLINUX_FS_PXELINUX) {
 +              more_printf("You are not currently using PXELINUX\n");
 +              return;
 +      }
  
 -  detect_pxe(hardware);
 -  more_printf("PXE\n");
 -  if (hardware->is_pxe_valid == false) {
 -    more_printf(" No valid PXE ROM found\n");
 -    return;
 -  }
 +      detect_pxe(hardware);
 +      more_printf("PXE\n");
 +      if (hardware->is_pxe_valid == false) {
 +              more_printf(" No valid PXE ROM found\n");
 +              return;
 +      }
  
 -  struct s_pxe *p = &hardware->pxe;
 -  more_printf(" PCI device no: %d \n", p->pci_device_pos);
 +      struct s_pxe *p = &hardware->pxe;
 +      more_printf(" PCI device no: %d \n", p->pci_device_pos);
  
-       if (hardware->pci_ids_return_code == -ENOPCIIDS) {
 -  if ((hardware->pci_ids_return_code == -ENOPCIIDS) ||  (p->pci_device==NULL)) {
 -    snprintf(buffer, sizeof(buffer),
 -       " PCI ID       : %04x:%04x[%04x:%04X] rev(%02x)\n",
 -       p->vendor_id, p->product_id, p->subvendor_id,
 -       p->subproduct_id, p->rev);
 -    snprintf(buffer, sizeof(buffer),
 -       " PCI Bus pos. : %02x:%02x.%02x\n", p->pci_bus,
 -       p->pci_dev, p->pci_func);
 -    more_printf(buffer);
 -  } else {
 -    snprintf(buffer, sizeof(buffer), " Manufacturer : %s \n",
 -       p->pci_device->dev_info->vendor_name);
 -    more_printf(buffer);
 -    snprintf(buffer, sizeof(buffer), " Product      : %s \n",
 -       p->pci_device->dev_info->product_name);
 -    more_printf(buffer);
 -  }
 -  more_printf(" Addresses    : %d.%d.%d.%d @ %s\n", p->ip_addr[0],
 -        p->ip_addr[1], p->ip_addr[2], p->ip_addr[3], p->mac_addr);
++      if (hardware->pci_ids_return_code == -ENOPCIIDS ||
++          (p->pci_device == NULL)) {
 +              snprintf(buffer, sizeof(buffer),
 +                       " PCI ID       : %04x:%04x[%04x:%04X] rev(%02x)\n",
 +                       p->vendor_id, p->product_id, p->subvendor_id,
 +                       p->subproduct_id, p->rev);
 +              snprintf(buffer, sizeof(buffer),
 +                       " PCI Bus pos. : %02x:%02x.%02x\n", p->pci_bus,
 +                       p->pci_dev, p->pci_func);
 +              more_printf(buffer);
 +      } else {
 +              snprintf(buffer, sizeof(buffer), " Manufacturer : %s \n",
 +                       p->pci_device->dev_info->vendor_name);
 +              more_printf(buffer);
 +              snprintf(buffer, sizeof(buffer), " Product      : %s \n",
 +                       p->pci_device->dev_info->product_name);
 +              more_printf(buffer);
 +      }
 +      more_printf(" Addresses    : %d.%d.%d.%d @ %s\n", p->ip_addr[0],
 +                  p->ip_addr[1], p->ip_addr[2], p->ip_addr[3], p->mac_addr);
  }
  
 -static void show_pxe_help()
 -{
 -  more_printf("Show supports the following commands : %s\n",
 -        CLI_SHOW_LIST);
 -}
 +struct cli_module_descr pxe_show_modules = {
 +      .modules = NULL,
 +      .nb_modules = 0,
 +      .default_callback = main_show_pxe,
 +};
  
 -static void pxe_show(char *item, struct s_hardware *hardware)
 -{
 -  if (!strncmp(item, CLI_SHOW_LIST, sizeof(CLI_SHOW_LIST) - 1)) {
 -    main_show_pxe(hardware);
 -    return;
 -  }
 -  show_pxe_help();
 -}
 -
 -void handle_pxe_commands(char *cli_line, struct s_hardware *hardware)
 -{
 -  if (!strncmp(cli_line, CLI_SHOW, sizeof(CLI_SHOW) - 1)) {
 -    pxe_show(strstr(cli_line, "show") + sizeof(CLI_SHOW), hardware);
 -    return;
 -  }
 -}
 +struct cli_mode_descr pxe_mode = {
 +      .mode = PXE_MODE,
 +      .name = CLI_PXE,
 +      .default_modules = NULL,
 +      .show_modules = &pxe_show_modules,
 +      .set_modules = NULL,
 +};
  #include <stdlib.h>
  #include <errno.h>
  
 -void main_show_vesa(struct s_hardware *hardware) {
 -  detect_vesa(hardware);
 -  if (hardware->is_vesa_valid==false) {
 -    more_printf("No VESA BIOS detected\n");
 -    return;
 -  }
 -  more_printf("VESA\n");
 -  more_printf(" Vesa version : %d.%d\n",hardware->vesa.major_version, hardware->vesa.minor_version);
 -  more_printf(" Vendor       : %s\n",hardware->vesa.vendor);
 -  more_printf(" Product      : %s\n",hardware->vesa.product);
 -  more_printf(" Product rev. : %s\n",hardware->vesa.product_revision);
 -  more_printf(" Software rev.: %d\n",hardware->vesa.software_rev);
 -  more_printf(" Memory (KB)  : %d\n",hardware->vesa.total_memory*64);
 -  more_printf(" Modes        : %d\n",hardware->vesa.vmi_count);
 +void main_show_vesa(int argc __unused, char **argv __unused,
 +                  struct s_hardware *hardware)
 +{
 +      detect_vesa(hardware);
 +      if (hardware->is_vesa_valid == false) {
 +              more_printf("No VESA BIOS detected\n");
 +              return;
 +      }
 +      more_printf("VESA\n");
 +      more_printf(" Vesa version : %d.%d\n", hardware->vesa.major_version,
 +                  hardware->vesa.minor_version);
 +      more_printf(" Vendor       : %s\n", hardware->vesa.vendor);
 +      more_printf(" Product      : %s\n", hardware->vesa.product);
 +      more_printf(" Product rev. : %s\n", hardware->vesa.product_revision);
 +      more_printf(" Software rev.: %s\n", hardware->vesa.software_rev);
 +      more_printf(" Memory (KB)  : %d\n", hardware->vesa.total_memory * 64);
 +      more_printf(" Modes        : %d\n", hardware->vesa.vmi_count);
  }
  
 -void show_vesa_modes(struct s_hardware *hardware) {
 -  detect_vesa(hardware);
 -  if (hardware->is_vesa_valid==false) {
 -    more_printf("No VESA BIOS detected\n");
 -    return;
 -  }
 -  clear_screen();
 -  more_printf(" ResH. x ResV x Bits : vga= : Vesa Mode\n",hardware->vesa.vmi_count);
 -  more_printf("----------------------------------------\n",hardware->vesa.vmi_count);
 +static void show_vesa_modes(int argc __unused, char **argv __unused,
 +                          struct s_hardware *hardware)
 +{
 +      detect_vesa(hardware);
 +      if (hardware->is_vesa_valid == false) {
 +              more_printf("No VESA BIOS detected\n");
 +              return;
 +      }
 +      clear_screen();
 +      more_printf(" ResH. x ResV x Bits : vga= : Vesa Mode\n",
 +                  hardware->vesa.vmi_count);
 +      more_printf("----------------------------------------\n",
 +                  hardware->vesa.vmi_count);
  
 -  for (int i=0;i<hardware->vesa.vmi_count;i++) {
 -    struct vesa_mode_info *mi=&hardware->vesa.vmi[i].mi;
 -    /* Sometimes, vesa bios reports 0x0 modes
 -     * We don't need to display that ones */
 -    if ((mi->h_res==0) || (mi->v_res==0)) continue;
 -    more_printf("%5u %5u    %3u     %3d     0x%04x\n",
 -                 mi->h_res, mi->v_res, mi->bpp, hardware->vesa.vmi[i].mode+0x200,hardware->vesa.vmi[i].mode);
 -  }
 +      for (int i = 0; i < hardware->vesa.vmi_count; i++) {
 +              struct vesa_mode_info *mi = &hardware->vesa.vmi[i].mi;
++              /*
++               * Sometimes, vesa bios reports 0x0 modes.
++               * We don't need to display that ones.
++               */
++              if ((mi->h_res == 0) || (mi->v_res == 0)) continue;
 +              more_printf("%5u %5u    %3u     %3d     0x%04x\n",
 +                          mi->h_res, mi->v_res, mi->bpp,
 +                          hardware->vesa.vmi[i].mode + 0x200,
 +                          hardware->vesa.vmi[i].mode);
 +      }
  }
  
 -static void show_vesa_help() {
 - more_printf("Show supports the following commands : %s %s\n",CLI_SHOW_LIST, CLI_MODES);
 -}
 -
 -static void vesa_show(char *item, struct s_hardware *hardware) {
 - if ( !strncmp(item, CLI_SHOW_LIST, sizeof(CLI_SHOW_LIST) - 1) ) {
 -   main_show_vesa(hardware);
 -   return;
 - }
 - if ( !strncmp(item, CLI_MODES, sizeof(CLI_MODES) - 1) ) {
 -   show_vesa_modes(hardware);
 -   return;
 - }
 - show_vesa_help();
 -}
 +struct cli_callback_descr list_vesa_show_modules[] = {
 +      {
 +       .name = CLI_MODES,
 +       .exec = show_vesa_modes,
 +       },
 +};
  
 -void handle_vesa_commands(char *cli_line, struct s_hardware *hardware) {
 - if ( !strncmp(cli_line, CLI_SHOW, sizeof(CLI_SHOW) - 1) ) {
 -    vesa_show(strstr(cli_line,"show")+ sizeof(CLI_SHOW), hardware);
 -    return;
 - }
 -}
 +struct cli_module_descr vesa_show_modules = {
 +      .modules = list_vesa_show_modules,
 +      .nb_modules = 1,
 +      .default_callback = main_show_vesa,
 +};
  
 +struct cli_mode_descr vesa_mode = {
 +      .mode = VESA_MODE,
 +      .name = CLI_VESA,
 +      .default_modules = NULL,
 +      .show_modules = &vesa_show_modules,
 +      .set_modules = NULL,
 +};
@@@ -887,35 -497,18 +887,39 @@@ void start_cli_mode(struct s_hardware *
  
                case KEY_ENTER:
                        more_printf("\n");
 -
 -                      /* We have to skip empty lines */
 -                      if (strlen(skipspace(cli.input))<1) {
 -                              reset_prompt(&cli);
++                      if (strlen(remove_spaces(hdt_cli.input)) < 1) {
++                              reset_prompt();
+                               break;
+                       }
 -                      if (cli.history_pos == MAX_HISTORY_SIZE-1) cli.history_pos=1;
 -                      strncpy(cli.history[cli.history_pos],skipspace(cli.input),sizeof(cli.history[cli.history_pos]));
 -                      cli.history_pos++;
 -                      if (cli.history_pos>cli.max_history_pos) cli.max_history_pos=cli.history_pos;
 -                      exec_command(skipspace(cli.input), &cli, hardware);
 -                      reset_prompt(&cli);
 +                      if (hdt_cli.history_pos == MAX_HISTORY_SIZE-1) hdt_cli.history_pos=1;
 +                      strncpy(hdt_cli.history[hdt_cli.history_pos],remove_spaces(hdt_cli.input),sizeof(hdt_cli.history[hdt_cli.history_pos]));
 +                      hdt_cli.history_pos++;
 +                      if (hdt_cli.history_pos>hdt_cli.max_history_pos) hdt_cli.max_history_pos=hdt_cli.history_pos;
 +                      exec_command(remove_spaces(hdt_cli.input), hardware);
 +                      reset_prompt();
 +                      break;
 +
 +                case KEY_DELETE:
 +                case KEY_DEL:
 +                        /* No need to delete when input is empty */
 +                        if (strlen(hdt_cli.input)==0) break;
 +                        /* Don't delete when cursor is at the end of the line */
 +                        if (hdt_cli.cursor_pos>=strlen(hdt_cli.input)) break;
 +
 +                      for (int c = hdt_cli.cursor_pos;
 +                           c < (int)strlen(hdt_cli.input) - 1; c++)
 +                              hdt_cli.input[c] = hdt_cli.input[c + 1];
 +                      hdt_cli.input[strlen(hdt_cli.input) - 1] = '\0';
 +
 +                      /* Clear the end of the line */
 +                      clear_end_of_line();
 +
 +                      /* Print the resulting buffer */
 +                      printf("%s", hdt_cli.input + hdt_cli.cursor_pos);
 +
 +                      /* Replace the cursor at the proper place */
 +                      if (strlen(hdt_cli.input + hdt_cli.cursor_pos)>0)
 +                              move_cursor_left(strlen(hdt_cli.input + hdt_cli.cursor_pos));
                        break;
  
                case KEY_BACKSPACE:
@@@ -194,7 -198,8 +199,8 @@@ void detect_disks(struct s_hardware *ha
      if (get_disk_params(drive, hardware->disk_info) != 0)
        continue;
      struct diskinfo *d = &hardware->disk_info[drive];
 -    printf
+     hardware->disks_count++;
 +    more_printf
          ("  DISK 0x%X: %s : %s %s: sectors=%d, s/t=%d head=%d : EDD=%s\n",
           drive, d->aid.model, d->host_bus_type, d->interface_type,
           d->sectors, d->sectors_per_track, d->heads,
@@@ -351,10 -388,10 +389,10 @@@ void detect_pci(struct s_hardware *hard
        get_class_name_from_pci_ids(hardware->pci_domain,
            hardware->pciids_path);
  
 -  printf("PCI: Resolving module names\n");
 +  more_printf("PCI: Resolving module names\n");
    /* Detecting which kernel module should match each device */
    hardware->modules_pcimap_return_code =
-       get_module_name_from_pci_ids(hardware->pci_domain,
+       get_module_name_from_pcimap(hardware->pci_domain,
             hardware->modules_pcimap_path);
  
    /* We try to detect the pxe stuff to populate the PXE: field of pci devices */
Simple merge