- smramc &= 0xC0;
- smramc |= 0x04;
-
- pci_write8(0, 0, 0, SMRAMC, smramc);
- printf("With any luck, ABSEG is now enabled as system RAM... enjoy!\n");
- } else {
- smramc = strtoul(argv[1], 0, 0);
-
- pci_write8(0, 0, 0, SMRAMC, smramc);
- printf("OK, set it up as you like.\n");
+ printf("SMRAM is locked, cannot load anything :-(\n");
+ return 1;
+ }
+
+ int ch;
+ int op = 0;
+ int new_smramc = smramc;
+
+ while ((ch = getopt_long(argc, argv, "ocsd:", longopts, NULL)) != -1)
+ {
+ switch (ch)
+ {
+ case 's':
+ if (op & OP_SET) usage(argc, argv);
+ op |= OP_SET;
+ new_smramc = strtoul(optarg, 0, 0);
+ break;
+ case 'o':
+ if (op & OP_SET) usage(argc, argv);
+ op |= OP_SET;
+ /* Set LSMM to 01 (ABseg = system RAM) */
+ new_smramc = (smramc & 0xF0) | 0x04;
+ break;
+ case 'c':
+ if (op & OP_SET) usage(argc, argv);
+ op |= OP_SET;
+ /* Set LSMM to 11 (ABseg = SMM RAM) */
+ new_smramc = (smramc & 0xF0) | 0x0C;
+ break;
+ case 'd':
+ op |= OP_DUMP;
+ break;
+ default:
+ usage(argc, argv);
+ }
+ }
+
+ if (!op) usage(argc, argv);
+
+ if (op & OP_DUMP)
+ {
+ dump(smramc, drp, drp2);
+ }
+
+ if (op & OP_SET)
+ {
+ pci_write8(0, 0, 0, SMRAMC, new_smramc);
+ if (op & OP_DUMP)
+ {
+ printf("SMRAM set to 0x%02x\n", new_smramc);
+ }