Example #1
0
int main(void)
{
  console_ansi_raw();

  printf("CLK_TCK = %d\n", (int)CLK_TCK);
  printf("Press keys, end with Ctrl-C...\n");

  for (;;) {
    cooked_keys();
    raw_keys();
  }
}
Example #2
0
int main(void)
{
    int rv= -1;
    const struct syslinux_version *sv;

    console_ansi_raw();
    sv = syslinux_version();
    if (sv->filesystem != SYSLINUX_FS_PXELINUX) {
	printf("%s: May only run in PXELINUX\n", app_name_str);
	return -2;
    }
    print_dhcp_pkt_all();
    return rv;
}
Example #3
0
int main(int argc, char *argv[])
{
    struct part_iter *iter = NULL;
    void *sbck = NULL;
    struct data_area fdat, hdat, sdat, data[3];
    int ndata = 0;

    console_ansi_raw();

    memset(&fdat, 0, sizeof fdat);
    memset(&hdat, 0, sizeof hdat);
    memset(&sdat, 0, sizeof sdat);

    opt_set_defs();
    if (opt_parse_args(argc, argv))
	goto bail;

#if 0
    /* Get max fixed disk number */
    fixed_cnt = *(uint8_t *)(0x475);

    /*
     * hmm, looks like we can't do that -
     * some bioses/vms just set it to 1
     * and go on living happily
     * any better options than hardcoded 0x80 - 0xFF ?
     */
#endif

    /* Get disk/part iterator matching user supplied options */
    if (find_dp(&iter))
	goto bail;

    /* Perform initial partition entry mangling */
    if (manglepe_fixchs(iter))
	goto bail;
    if (manglepe_hide(iter))
	goto bail;

    /* Load the boot file */
    if (opt.file) {
	fdat.base = (opt.fseg << 4) + opt.foff;

	if (loadfile(opt.file, &fdat.data, &fdat.size)) {
	    error("Couldn't read the boot file.");
	    goto bail;
	}
	if (fdat.base + fdat.size > dosmax) {
	    error("The boot file is too big to load at this address.");
	    goto bail;
	}
    }

    /* Load the sector */
    if (opt.sect) {
	sdat.base = (opt.sseg << 4) + opt.soff;
	sdat.size = iter->di.bps;

	if (sdat.base + sdat.size > dosmax) {
	    error("The sector cannot be loaded at such high address.");
	    goto bail;
	}
	if (!(sdat.data = disk_read_sectors(&iter->di, iter->abs_lba, 1))) {
	    error("Couldn't read the sector.");
	    goto bail;
	}
	if (opt.save) {
	    if (!(sbck = malloc(sdat.size))) {
		critm();
		goto bail;
	    }
	    memcpy(sbck, sdat.data, sdat.size);
	}
	if (opt.file && opt.maps && overlap(&fdat, &sdat)) {
	    warn("The sector won't be mmapped, as it would conflict with the boot file.");
	    opt.maps = false;
	}
    }

    /* Prep the handover */
    if (opt.hand) {
	if (setup_handover(iter, &hdat))
	    goto bail;
	/* Verify possible conflicts */
	if ( ( opt.file && overlap(&fdat, &hdat)) ||
	     ( opt.maps && overlap(&sdat, &hdat)) ) {
	    warn("Handover area won't be prepared,\n"
		  "as it would conflict with the boot file and/or the sector.");
	    opt.hand = false;
	}
    }

    /* Adjust registers */

    mangler_init(iter);
    mangler_handover(iter, &hdat);
    mangler_grldr(iter);

    /* Patching functions */

    if (manglef_isolinux(&fdat))
	goto bail;

    if (manglef_grub(iter, &fdat))
	goto bail;
#if 0
    if (manglef_drmk(&fdat))
	goto bail;
#endif
    if (manglef_bpb(iter, &fdat))
	goto bail;

    if (mangles_bpb(iter, &sdat))
	goto bail;

    if (mangles_save(iter, &sdat, sbck))
	goto bail;

    if (manglesf_bss(&sdat, &fdat))
	goto bail;

    /* This *must* be after BPB saving or copying */
    if (mangles_cmldr(&sdat))
	goto bail;

    /*
     * Prepare boot-time mmap data. We should to it here, as manglers could
     * potentially alter some of the data.
     */

    if (opt.file)
	memcpy(data + ndata++, &fdat, sizeof fdat);
    if (opt.maps)
	memcpy(data + ndata++, &sdat, sizeof sdat);
    if (opt.hand)
	memcpy(data + ndata++, &hdat, sizeof hdat);

#ifdef DEBUG
    dprintf("iter->di dsk, bps: %X, %u\niter->di lbacnt, C*H*S: %"PRIu64", %u\n"
	   "iter->di C, H, S: %u, %u, %u\n",
	iter->di.disk, iter->di.bps,
	iter->di.lbacnt, iter->di.cyl * iter->di.head * iter->di.spt,
	iter->di.cyl, iter->di.head, iter->di.spt);
    dprintf("iter idx: %d\n", iter->index);
    dprintf("iter lba: %"PRIu64"\n", iter->abs_lba);
    if (opt.hand)
	dprintf("hand lba: %u\n",
		((struct disk_dos_part_entry *)hdat.data)->start_lba);
#endif

    if (opt.warn) {
	puts("Press any key to continue booting...");
	wait_key();
    }

    if (ndata && !opt.brkchain) /* boot only if we actually chainload */
	do_boot(data, ndata);
    else
	puts("Service-only run completed, exiting.");
bail:
    pi_del(&iter);
    /* Free allocated areas */
    free(fdat.data);
    free(sdat.data);
    free(hdat.data);
    free(sbck);
    return 255;
}
Example #4
0
int main(int argc, char *argv[])
{
    char **args[3];
    int i=0;
    int n=0;
    bool hardware_matches = true;
    bool multicore = false;
    bool dryrun = false;
    bool debug = false;

    s_cpu cpu;
    console_ansi_raw();
    detect_cpu(&cpu);

    /* If no argument got passed, let's show the usage */
    if (argc == 1) {
	    usage();
	    return -1;
    }

    for (i = 1; i < argc; i++) {
	if (!strcmp(argv[i], "--")) {
	    argv[i] = NULL;
	    args[n++] = &argv[i + 1];
	} else if (!strcmp(argv[i], "64")) {
	    if (debug)
		printf(" 64bit     : %s on this system\n",
		       show_bool(cpu.flags.lm));
	    hardware_matches = cpu.flags.lm && hardware_matches;
	} else if (!strcmp(argv[i], "pae")) {
	    if (debug)
		printf(" pae       : %s on this system\n",
		       show_bool(cpu.flags.pae));
	    hardware_matches = cpu.flags.pae && hardware_matches;
	} else if (!strcmp(argv[i], "hvm")) {
	    if (debug)
		printf(" hvm       : %s on this system\n",
		       show_bool((cpu.flags.vmx || cpu.flags.svm)));
	    hardware_matches = (cpu.flags.vmx || cpu.flags.svm)
		&& hardware_matches;
	} else if (!strcmp(argv[i], "multicore")) {
	    if (debug)
		printf(" multicore : %d cores on this system\n", cpu.num_cores);
	    if (cpu.num_cores > 1)
		multicore = true;
	    hardware_matches = multicore && hardware_matches;
	} else if (!strcmp(argv[i], "smp")) {
	    if (debug)
		printf(" smp       : %s on this system\n", show_bool(cpu.flags.smp));
	    hardware_matches = cpu.flags.smp && hardware_matches;
	} else if (!strcmp(argv[i], "dry-run")) {
	    dryrun = true;
	} else if (!strcmp(argv[i], "debug")) {
	    debug = true;
	}
	if (n >= 2)
	    break;
    }
    while (n < 2) {
	args[n] = args[n - 1];
	n++;
    }
    if (debug) {
	printf("\nBooting labels are : '%s' or '%s'\n", *args[0], *args[1]);
	printf("Hardware requirements%smatch this system, let's booting '%s'\n",
	       hardware_matches ? " " : " doesn't ",
	       hardware_matches ? *args[0] : *args[1]);
	printf("Sleeping 5sec before booting\n");
	if (!dryrun)
	    sleep(5);
    }

    if (!dryrun)
	boot_args(hardware_matches ? args[0] : args[1]);
    else
	printf("Dry-run mode, let's exiting\n");

    return -1;
}