- Timestamp:
- Sep 1, 2011, 1:32:43 PM (14 years ago)
- Location:
- trunk/src/os2ahci
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/os2ahci/os2ahci.c
r121 r122 33 33 34 34 /* parse integer command line parameter */ 35 #define drv_parm_int(s, value, type, radix) \36 { \37 char _far *_ep; \38 if ((s)[1] != ':') { \39 cprintf(" missing colon (:) after /%c\n", *(s));\40 goto init_fail; \41 } \42 value = (type) strtol((s) + 2, \43 (const char _far* _far*) &_ep, \44 radix); \45 s = _ep; \35 #define drv_parm_int(s, value, type, radix) \ 36 { \ 37 char _far *_ep; \ 38 if ((s)[1] != ':') { \ 39 cprintf("%s: missing colon (:) after /%c\n", drv_name, *(s)); \ 40 goto init_fail; \ 41 } \ 42 value = (type) strtol((s) + 2, \ 43 (const char _far* _far*) &_ep, \ 44 radix); \ 45 s = _ep; \ 46 46 } 47 47 … … 73 73 int thorough_scan = 1; /* if != 0, perform thorough PCI scan */ 74 74 int init_reset; /* if != 0, reset ports during init */ 75 int verbosity; /* if > 0, show some info during boot */ 75 int verbosity = 1; /* == 1 -> show sign on banner 76 * > 1 -> show adapter info during boot */ 76 77 77 78 PFN Device_Help = 0; /* pointer to device helper entry point */ … … 83 84 USHORT add_handle; /* driver handle (RegisterDeviceClass) */ 84 85 UCHAR timer_pool[TIMER_POOL_SIZE]; /* timer pool */ 86 char drv_name[] = "OS2AHCI"; /* driver name as string */ 85 87 86 88 /* resource manager driver information structure */ 87 89 DRIVERSTRUCT rm_drvinfo = { 88 "OS2AHCI",/* driver name */90 drv_name, /* driver name */ 89 91 "AHCI SATA Driver", /* driver description */ 90 92 "GNU", /* vendor name */ … … 112 114 u8 track_size[MAX_AD][AHCI_MAX_PORTS]; 113 115 114 static char init_msg[] = " OS2AHCIdriver version %d.%02d\n";115 static char exit_msg[] = " OS2AHCIdriver *not* installed\n";116 static char init_msg[] = "%s driver version %d.%02d\n"; 117 static char exit_msg[] = "%s driver *not* installed\n"; 116 118 117 119 /* ----------------------------- start of code ----------------------------- */ … … 179 181 init_libc(); 180 182 181 /* print initialization message */182 cprintf(init_msg, VERSION / 100, VERSION % 100);183 184 #ifdef ECS_BUILD185 cprintf("This driver is licensed for use only in conjunction with eComStation.");186 #endif187 188 183 /* register driver with resource manager */ 189 184 if ((rmrc = RMCreateDriver(&rm_drvinfo, &rm_drvh)) != RMRC_SUCCESS) { 190 cprintf("failed to register driver with resource manager (rc = %d)\n", rmrc); 185 cprintf("%s: failed to register driver with resource manager (rc = %d)\n", 186 drv_name, rmrc); 191 187 goto init_fail; 192 188 } … … 205 201 case '\0': 206 202 /* end of command line; can only happen if command line is incorrect */ 207 cprintf(" incomplete command line option\n");203 cprintf("%s: incomplete command line option\n", drv_name); 208 204 goto init_fail; 209 205 … … 223 219 drv_parm_int(s, device, u16, 16); 224 220 if (add_pci_id(vendor, device)) { 225 cprintf(" failed to add PCI ID %04x:%04x\n", vendor, device);221 cprintf("%s: failed to add PCI ID %04x:%04x\n", drv_name, vendor, device); 226 222 goto init_fail; 227 223 } … … 243 239 drv_parm_int(s, adapter_index, int, 10); 244 240 if (adapter_index < 0 || adapter_index >= MAX_AD) { 245 cprintf(" invalid adapter index (%d)\n", adapter_index);241 cprintf("%s: invalid adapter index (%d)\n", drv_name, adapter_index); 246 242 goto init_fail; 247 243 } … … 252 248 drv_parm_int(s, port_index, int, 10); 253 249 if (port_index < 0 || port_index >= AHCI_MAX_PORTS) { 254 cprintf(" invalid port index (%d)\n", port_index);250 cprintf("%s: invalid port index (%d)\n", drv_name, port_index); 255 251 goto init_fail; 256 252 } … … 289 285 break; 290 286 default: 291 cprintf(" invalid link parameter (%c)\n", *s);287 cprintf("%s: invalid link parameter (%c)\n", drv_name, *s); 292 288 goto init_fail; 293 289 } … … 308 304 break; 309 305 306 case 'q': 307 /* be quiet */ 308 verbosity = -1000; 309 break; 310 310 311 default: 311 cprintf(" unknown option: /%c\n", *s);312 cprintf("%s: unknown option: /%c\n", drv_name, *s); 312 313 goto init_fail; 313 314 } 314 315 } 315 316 } 317 318 /* print initialization message */ 319 cvprintf(init_msg, drv_name, VERSION / 100, VERSION % 100); 320 321 #ifdef ECS_BUILD 322 cvprintf("This driver is licensed for use only in conjunction with eComStation."); 323 #endif 316 324 317 325 if (debug) { … … 334 342 mdelay_cal(); 335 343 336 if (DevHelp_RegisterDeviceClass( "OS2AHCI", (PFN) add_entry, 0, 1,344 if (DevHelp_RegisterDeviceClass(drv_name, (PFN) add_entry, 0, 1, 337 345 &add_handle)) { 338 cprintf(" error: couldn't register device class\n");346 cprintf("%s: couldn't register device class\n", drv_name); 339 347 goto init_fail; 340 348 } … … 344 352 DevHelp_AllocateCtxHook(mk_NPFN(reset_hook), &reset_ctxhook_h) != 0 || 345 353 DevHelp_AllocateCtxHook(mk_NPFN(engine_hook), &engine_ctxhook_h)) { 346 cprintf(" failed to allocate task-time context hooks\n");354 cprintf("%s: failed to allocate task-time context hooks\n", drv_name); 347 355 goto init_fail; 348 356 } … … 354 362 } else { 355 363 /* no adapters found */ 356 c printf(" No adapters found.\n");364 cvprintf(" No adapters found.\n"); 357 365 } 358 366 … … 372 380 } 373 381 374 c printf(exit_msg);382 cvprintf(exit_msg, drv_name); 375 383 return(STDON | ERROR_I24_QUIET_INIT_FAIL); 376 384 } -
trunk/src/os2ahci/os2ahci.h
r121 r122 104 104 #define dddprintf if (debug > 2) printf 105 105 #define dddphex if (debug > 2) phex 106 107 /* verbosity console print macros */ 108 #define cvprintf if (verbosity > 0) cprintf 109 #define cvvprintf if (verbosity > 1) cprintf 106 110 107 111 /* TRACE macros (for our internal ring buffer trace) */ … … 525 529 extern USHORT add_handle; /* adapter device driver handle */ 526 530 extern UCHAR timer_pool[]; /* timer pool */ 531 extern char drv_name[]; /* driver name as string ("OS2AHCI") */ 527 532 528 533 extern PCI_ID pci_ids[]; /* SATA adapter PCI IDs */ -
trunk/src/os2ahci/pci.c
r112 r122 417 417 memset(&parm, 0x00, sizeof(parm)); 418 418 if (oemhlp_call(OH_BIOS_INFO, &parm, &data) != OH_SUCCESS) { 419 cprintf(" couldn't get PCI BIOS information\n");419 cprintf("%s: couldn't get PCI BIOS information\n", drv_name); 420 420 return; 421 421 } … … 614 614 615 615 /* found a supported AHCI device */ 616 if (verbosity > 0) { 617 cprintf("found AHCI device: %s %s (%04x:%04x)\n" 616 cvvprintf("found AHCI device: %s %s (%04x:%04x)\n" 618 617 " class:0x%06lx bus:%d devfunc:0x%02x\n", 619 618 vendor_from_id(vendor), device_from_id(device), 620 619 vendor, device, 621 620 class, bus, dev_func); 622 }623 621 624 622 /* make sure we got room in the adapter information array */ 625 623 if (ad_info_cnt >= MAX_AD - 1) { 626 cprintf(" error: too many AHCI devices\n");624 cprintf("%s: too many AHCI devices\n", drv_name); 627 625 return; 628 626 } … … 665 663 ret = RMAllocResource(rm_drvh, &ad_info->rm_irq, &resource); 666 664 if (ret != RMRC_SUCCESS) { 667 cprintf(" error: couldn't register IRQ %d (rc = %s)\n", irq, rmerr(ret));665 cprintf("%s: couldn't register IRQ %d (rc = %s)\n", drv_name, irq, rmerr(ret)); 668 666 return; 669 667 } … … 689 687 if (i == AHCI_PCI_BAR) { 690 688 if (resource.ResourceType != RS_TYPE_MEM) { 691 cprintf(" error: BAR #5 must be an MMIO region\n");689 cprintf("%s: BAR #5 must be an MMIO region\n", drv_name); 692 690 goto add_pci_fail; 693 691 } … … 700 698 ret = RMAllocResource(rm_drvh, ad_info->rm_bars + i, &resource); 701 699 if (ret != RMRC_SUCCESS) { 702 cprintf("error: couldn't register [MM]IO region (rc = %s)\n", rmerr(ret)); 700 cprintf("%s: couldn't register [MM]IO region (rc = %s)\n", 701 drv_name, rmerr(ret)); 703 702 goto add_pci_fail; 704 703 } … … 707 706 708 707 if (ad_info->mmio_phys == 0) { 709 cprintf(" error: couldn't determine MMIO base address\n");708 cprintf("%s: couldn't determine MMIO base address\n", drv_name); 710 709 goto add_pci_fail; 711 710 } … … 724 723 if (DevHelp_AllocPhys((long) AHCI_PORT_PRIV_DMA_SZ * AHCI_MAX_PORTS, 725 724 MEMTYPE_ABOVE_1M, &ad_info->dma_buf_phys) != 0) { 726 cprintf(" error: couldn't allocate DMA scratch buffers for AHCI ports\n");725 cprintf("%s: couldn't allocate DMA scratch buffers for AHCI ports\n", drv_name); 727 726 ad_info->dma_buf_phys = 0; 728 727 goto add_pci_fail; … … 731 730 /* allocate GDT selectors for memory-mapped I/O and DMA scratch buffers */ 732 731 if (DevHelp_AllocGDTSelector(gdt, PORT_DMA_BUF_SEGS + 1) != 0) { 733 cprintf(" error: couldn't allocate GDT selectors\n");732 cprintf("%s: couldn't allocate GDT selectors\n", drv_name); 734 733 memset(gdt, 0x00, sizeof(gdt)); 735 734 goto add_pci_fail; … … 739 738 if (DevHelp_PhysToGDTSelector(ad_info->mmio_phys, 740 739 (USHORT) ad_info->mmio_size, gdt[0]) != 0) { 741 cprintf(" error: couldn't map MMIO address to GDT selector\n");740 cprintf("%s: couldn't map MMIO address to GDT selector\n", drv_name); 742 741 goto add_pci_fail; 743 742 } … … 749 748 750 749 if (DevHelp_PhysToGDTSelector(addr, len, gdt[i+1]) != 0) { 751 cprintf(" error: couldn't map DMA scratch buffer to GDT selector\n");750 cprintf("%s: couldn't map DMA scratch buffer to GDT selector\n", drv_name); 752 751 goto add_pci_fail; 753 752 } … … 780 779 ret = RMCreateAdapter(rm_drvh, &ad_info->rm_adh, &adapter, NULL, rc_list); 781 780 if (ret != RMRC_SUCCESS) { 782 cprintf(" error: couldn't register adapter (rc = %s)\n", rmerr(ret));781 cprintf("%s: couldn't register adapter (rc = %s)\n", drv_name, rmerr(ret)); 783 782 goto add_pci_fail; 784 783 } … … 827 826 parm.read_config.size = size; 828 827 if ((rc = oemhlp_call(OH_READ_CONFIG, &parm, &data) != OH_SUCCESS)) { 829 cprintf(" error: couldn't read config space (bus = %d, dev_func = 0x%02x, indx = 0x%02x, rc = %d)\n",830 bus, dev_func, indx, rc);828 cprintf("%s: couldn't read config space (bus = %d, dev_func = 0x%02x, indx = 0x%02x, rc = %d)\n", 829 drv_name, bus, dev_func, indx, rc); 831 830 return(rc); 832 831 } … … 854 853 855 854 if ((rc = oemhlp_call(OH_WRITE_CONFIG, &parm, &data) != OH_SUCCESS)) { 856 cprintf(" error: couldn't write config space (bus = %d, dev_func = 0x%02x, indx = 0x%02x, rc = %d)\n",857 bus, dev_func, indx, rc);855 cprintf("%s: couldn't write config space (bus = %d, dev_func = 0x%02x, indx = 0x%02x, rc = %d)\n", 856 drv_name, bus, dev_func, indx, rc); 858 857 return(rc); 859 858 } … … 877 876 oemhlp.ProtIDCEntry == NULL || 878 877 oemhlp.ProtIDC_DS == 0) { 879 cprintf(" couldn't attach to OEMHLP$\n");878 cprintf("%s: couldn't attach to OEMHLP$\n", drv_name); 880 879 return(OH_NOT_SUPPORTED); 881 880 } … … 973 972 pci_write_conf(bus, dev_func, PCI_BAR(i), sizeof(u32), bar_addr) != OH_SUCCESS) { 974 973 975 cprintf(" error: couldn't determine [MM]IO size\n");974 cprintf("%s: couldn't determine [MM]IO size\n", drv_name); 976 975 if (bar_addr != 0) { 977 976 pci_write_conf(bus, dev_func, PCI_BAR(i), sizeof(u32), bar_addr); -
trunk/src/os2ahci/trace.c
r116 r122 71 71 /* failed, too. Give up */ 72 72 ahci_trace_buf.phys_addr = 0; 73 cprintf(" OS2AHCIwarning: failed to allocate %dk trace buffer\n",74 AHCI_TRACE_BUF_SIZE / 1024);73 cprintf("%s warning: failed to allocate %dk trace buffer\n", 74 drv_name, AHCI_TRACE_BUF_SIZE / 1024); 75 75 return; 76 76 }
Note:
See TracChangeset
for help on using the changeset viewer.