1 /* 2 * Channel Subsystem tests 3 * 4 * Copyright (c) 2020 IBM Corp 5 * 6 * Authors: 7 * Pierre Morel <pmorel@linux.ibm.com> 8 * 9 * This code is free software; you can redistribute it and/or modify it 10 * under the terms of the GNU General Public License version 2. 11 */ 12 13 #include <libcflat.h> 14 #include <alloc_phys.h> 15 #include <asm/page.h> 16 #include <string.h> 17 #include <interrupt.h> 18 #include <asm/arch_def.h> 19 20 #include <css.h> 21 22 static int test_device_sid; 23 24 static void test_enumerate(void) 25 { 26 test_device_sid = css_enumerate(); 27 if (test_device_sid & SCHID_ONE) { 28 report(1, "Schid of first I/O device: 0x%08x", test_device_sid); 29 return; 30 } 31 report(0, "No I/O device found"); 32 } 33 34 static void test_enable(void) 35 { 36 int cc; 37 38 if (!test_device_sid) { 39 report_skip("No device"); 40 return; 41 } 42 43 cc = css_enable(test_device_sid, IO_SCH_ISC); 44 45 report(cc == 0, "Enable subchannel %08x", test_device_sid); 46 } 47 48 static struct { 49 const char *name; 50 void (*func)(void); 51 } tests[] = { 52 { "enumerate (stsch)", test_enumerate }, 53 { "enable (msch)", test_enable }, 54 { NULL, NULL } 55 }; 56 57 int main(int argc, char *argv[]) 58 { 59 int i; 60 61 report_prefix_push("Channel Subsystem"); 62 for (i = 0; tests[i].name; i++) { 63 report_prefix_push(tests[i].name); 64 tests[i].func(); 65 report_prefix_pop(); 66 } 67 report_prefix_pop(); 68 69 return report_summary(); 70 } 71