void fob_exit() { fob_stream_stop(); fob_flush(); rtsset(0); fob_fbbreset(); fob_flush(); sio_exit(); };
int main(int argc, char *argv[]) { struct chip chip; char args, *filename; int i = 0, gpio[10] = {-1}, level = -1, blink = 0, ret; unsigned int gpio_base_addr; initcheck(); if (iopl(3)) { perror(NULL); exit(1); } /* parsing arguments */ while ((args = getopt(argc, argv, "bc:g:ho:")) != -1) { switch (args) { case 'b': blink = 1; break; case 'c': filename = optarg; break; case 'g': optind--; for (; optind < argc && *argv[optind] != '-'; optind++) gpio[i++] = atoi(argv[optind]); total = i; break; case 'o': level = atoi(optarg); break; case ':': case 'h': case '?': usage(1); break; } } #ifdef DEBUG DBG("filename = %s\n", filename); for (i = 0; i < total; i++) DBG("gpio[%d] = %d\n", i, gpio[i]); DBG("level = %d\n", level); #endif if (filename == NULL || gpio[0] == -1 || level == -1) { usage(1); } /* read configuration file */ read_config(filename, chip.name, &gpio_base_addr); DBG("chip.name = %s, addr = %x\n", chip.name, gpio_base_addr); /* test start */ if (strncmp(chip.name, "PCH", 3) == 0) { for (i = 0; i < total; i++) { if (blink == 1) { if (pch_gpio_blink_config(gpio[i], level, gpio_base_addr)) { ERR("only support GPIO0 to GPIO31.\n"); usage(1); } } else { pch_gpio_config(gpio[i], level, gpio_base_addr); } } } else { for (i = 0; i < total; i++) { EFER = gpio_base_addr; EFDR = EFER + 1; sio_enter(chip.name); sio_gpio_config(gpio[i], level, &chip); sio_exit(); } } /* test end */ return 0; }
int main(int argc, char *argv[]) { char args, chip[10]; int i = 0, gpio[10] = {-1}, level = -1; unsigned int gpio_base_addr = 0xFFFF; if (iopl(3)) { perror(NULL); exit(1); } /* parsing arguments */ while ((args = getopt(argc, argv, "a:c:d:g:ho:")) != -1) { switch (args) { case 'a': gpio_base_addr = (unsigned int)strtol(optarg, NULL, 16); break; case 'c': if (strncmp("NCT", optarg, 3) != 0 && strncmp("FIN", optarg, 3) != 0) { printf("Unsupported chip: %s\n", optarg); } else { strcpy(chip, optarg); printf("%s\n", chip); } break; case 'g': optind--; for (; optind < argc && *argv[optind] != '-'; optind++) gpio[i++] = atoi(argv[optind]); total = i; break; case 'o': level = atoi(optarg); break; case ':': case 'h': case '?': usage(1); break; } } /* check the gpio base address */ if (gpio_base_addr == 0x1C00 || gpio_base_addr == 0x500) { /* PCH */ for (i = 0; i < total; i++) { gpio_config(gpio[i], level, gpio_base_addr); } } else { /* SIO */ for (i = 0; i < total; i++) { EFER = gpio_base_addr; EFDR = EFER + 1; sio_enter(chip); sio_gpio_config(gpio[i], level, chip); sio_exit(); } } /* test end */ return 0; }