[Fault-injection-developer] Updated: fi_test
Status: Alpha
Brought to you by:
rustyl
From: Wang, S. <sta...@in...> - 2003-01-07 09:02:17
|
I added PIO access function in the fi_test, hence we could test fi_dbp with it. Here is the patch: # This is a BitKeeper generated patch for the following project: # Project Name: Linux kernel tree # This patch format is intended for GNU patch command version 2.5 or higher. # This patch includes the following deltas: # ChangeSet 1.972 -> 1.972.2.3 # drivers/fi/testing/fi_test.c 1.12 -> 1.13 # # The following is the BitKeeper ChangeSet Log # -------------------------------------------- # 03/01/07 st...@ma... 1.972.2.2 # Add PIO access support for FITH's test module. # -------------------------------------------- # 03/01/07 lo...@ha... 1.974 # Merge bk://fau...@fa.../linux-2.5 # into hawk.sh.intel.com:/home/work/2.5-fi # -------------------------------------------- # 03/01/07 lo...@ha... 1.975 # Add missed license # -------------------------------------------- # diff -Nru a/drivers/fi/testing/fi_test.c b/drivers/fi/testing/fi_test.c --- a/drivers/fi/testing/fi_test.c Tue Jan 7 16:43:10 2003 +++ b/drivers/fi/testing/fi_test.c Tue Jan 7 16:43:10 2003 @@ -28,17 +28,30 @@ #define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n", MY_NAME , ## arg) +#define PP_BASE 0x378 #define MM_BASE 0x00001000 static int debug; void *mmio_address; volatile unsigned long global_counter = 0; +ssize_t io_show(struct subsystem *s, char *page, + size_t count, loff_t off); +ssize_t io_store(struct subsystem *s, const char *page, + size_t count, loff_t off); + ssize_t mmio_show(struct subsystem *s, char *page, size_t count, loff_t off); ssize_t mmio_store(struct subsystem *s, const char *page, size_t count, loff_t off); +struct subsys_attribute io = +{ + .attr = { .name = "io", .mode = 0644 }, + .show = io_show, + .store = io_store, +}; + struct subsys_attribute mmio = { .attr = { .name = "mmio", .mode = 0644 }, @@ -77,11 +90,49 @@ return strlen(page); } +void do_io_access(int write, int type) +{ + unsigned char value=0; + if (write) + info("Write 0X5A* to parellel port register!\n"); + else + info("Expect read 0X5A* from parellel port register!\n"); + + switch (type){ + case 0: + outb(0x5a, PP_BASE); + value = inb(PP_BASE); + break; + case 1: + outw(0x5a, PP_BASE); + value = inw(PP_BASE); + break; + case 2: + outl(0x5a, PP_BASE); + value = inl(PP_BASE); + break; + case 4: + outw_p(0x5a, PP_BASE); + value = inw_p(PP_BASE); + break; + case 5: + outl_p(0x5a, PP_BASE); + value = inl_p(PP_BASE); + break; + default: + break; + } + if (write) + info("%#X was write to parellel port register!\n",value); + else + info("%#X was read from parellel port register!\n",value); +} + void do_mm_io_access(int write, int type) { unsigned long value=0; if (write) - info("write 0X5A* to MMI/O address"); + info("Write 0X5A* to MMI/O address"); else info("Expect read 0X5A* from MMI/O address"); @@ -108,6 +159,70 @@ } +ssize_t io_show(struct subsystem *s, char *page, + size_t count, loff_t off) +{ + return 0; +} + +ssize_t io_store(struct subsystem *s, const char *page, + size_t count, loff_t off) +{ + char cmd[16]; + char len[16]; + int num = 0; + + if (off) return count; + + num = sscanf(page, "%15s %15s", cmd, len); + + if (num < 0) { + err("Unknow command format!"); + return count; + } + + LOG_TIME; + if (!strncmp(cmd, "read", 4)) { + if (!strncmp(len, "byte", 4)) { + info("COMMAND_IO_READ"); + do_io_access(0,0); + goto done; + } + if (!strncmp(len, "word", 4)) { + info("COMMAND_IO_READW"); + do_io_access(0,1); + goto done; + } + if (!strncmp(len, "long", 4)) { + info("COMMAND_IO_READL"); + do_io_access(0,2); + goto done; + } + err("Invalid length!"); + } else if (!strncmp(cmd, "write", 5)) { + if (!strncmp(len, "byte", 4)) { + info("COMMAND_IO_WRITE"); + do_io_access(1,0); + goto done; + } + if (!strncmp(len, "word", 4)) { + info("COMMAND_IO_WRITEW"); + do_io_access(1,1); + goto done; + } + if (!strncmp(len, "long", 4)) { + info("COMMAND_IO_WRITEL"); + do_io_access(1,2); + goto done; + } + err("Invalid length!"); + } else { + err("Unknow command!"); + } +done: + return count; +} + ssize_t mmio_show(struct subsystem *s, char *page, size_t count, loff_t off) { @@ -177,6 +292,7 @@ dbg("Initialize fith_test."); subsystem_register(&fith_test); subsys_create_file(&fith_test, &mmio); + subsys_create_file(&fith_test, &io); mmio_address = ioremap(MM_BASE, 0x8); info("mmio_address = %p", mmio_address); @@ -189,6 +305,7 @@ static void __exit fi_test_exit (void) { dbg("Cleanup fith_test."); + subsys_remove_file(&fith_test, &io); subsys_remove_file(&fith_test, &mmio); subsystem_unregister(&fith_test); iounmap(mmio_address); Your Sincerely, Stanley Wang SW Engineer, Intel Corporation. Intel China Software Lab. Tel: 021-52574545 ext. 1171 iNet: 8-752-1171 Opinions expressed are those of the author and do not represent Intel Corporation |