Пример #1
0
static void *get_buffer(struct memory_bitmap *bm, struct chain_allocator *ca)
{
	struct pbe *pbe;
	struct page *page = pfn_to_page(memory_bm_next_pfn(bm));

	if (PageNosave(page) && PageNosaveFree(page))
		/* We have allocated the "original" page frame and we can
		 * use it directly to store the loaded page.
		 */
		return page_address(page);

	/* The "original" page frame has not been allocated and we have to
	 * use a "safe" page frame to store the loaded page.
	 */
	pbe = chain_alloc(ca, sizeof(struct pbe));
	if (!pbe) {
		swsusp_free();
		return NULL;
	}
	pbe->orig_address = (unsigned long)page_address(page);
	pbe->address = (unsigned long)safe_pages_list;
	safe_pages_list = safe_pages_list->next;
	pbe->next = restore_pblist;
	restore_pblist = pbe;
	return (void *)pbe->address;
}
Пример #2
0
static inline struct zone_bitmap *
create_zone_bm_list(unsigned int nr_zones, struct chain_allocator *ca)
{
	struct zone_bitmap *zbmlist = NULL;

	while (nr_zones-- > 0) {
		struct zone_bitmap *zbm;

		zbm = chain_alloc(ca, sizeof(struct zone_bitmap));
		if (!zbm)
			return NULL;

		zbm->next = zbmlist;
		zbmlist = zbm;
	}
	return zbmlist;
}
Пример #3
0
static inline struct bm_block *
create_bm_block_list(unsigned int nr_blocks, struct chain_allocator *ca)
{
	struct bm_block *bblist = NULL;

	while (nr_blocks-- > 0) {
		struct bm_block *bb;

		bb = chain_alloc(ca, sizeof(struct bm_block));
		if (!bb)
			return NULL;

		bb->next = bblist;
		bblist = bb;
	}
	return bblist;
}
Пример #4
0
int
sym_callchain_add(sym_t *sym, uint64_t *ips, int ips_num,
	sym_chainlist_t *list)
{
	sym_callchain_t *chain;

	if ((chain = chain_find(list, ips, ips_num)) != NULL) {
		chain->naccess++;
		return (0);	
	}
	
	if ((chain = chain_alloc(sym, ips, ips_num)) == NULL) {
		return (-1);
	}

	chainlist_attach_tail(list, chain);
	return (0);
}
Пример #5
0
int
main( int argc, const char **argv )
{
    int go;
    int i;

#ifdef ENABLE_NLS
    /* l10n support */
    setlocale( LC_ALL, "" );
    bindtextdomain( PACKAGE, LOCALEDIR );
    textdomain( PACKAGE );
#endif /* ENABLE_NLS */

    /* input from files */
    if (argc > 1) {
        for (i = 1; i < argc; i++) {
            chain = chain_alloc();
            if (!chain) {
                printf( _("Out of memory\n") );
                return -1;
            }

            go = jtag_parse_file( argv[i] );
            cleanup();
            if (go < 0) {
                printf( _("Unable to open file `%s'!\n"), argv[i] );
                break;
            }
        }
        return 0;
    }

    /* input from stdin */
    if (!isatty(0)) {
        chain = chain_alloc();
        if (!chain) {
            printf( _("Out of memory\n") );
            return -1;
        }

        jtag_parse_stream( stdin );

        cleanup();

        return 0;
    }

    /* interactive */
    printf(
        _("%s\n"
          "Copyright (C) 2002, 2003 ETC s.r.o.\n"
          "%s is free software, covered by the GNU General Public License, and you are\n"
          "welcome to change it and/or distribute copies of it under certain conditions.\n"
          "There is absolutely no warranty for %s.\n\n"), PACKAGE_STRING, PACKAGE_NAME, PACKAGE_NAME
    );

    chain = chain_alloc();
    if (!chain) {
        printf( _("Out of memory\n") );
        return -1;
    }

    printf( _("Warning: %s may damage your hardware! Type \"quit\" to exit!\n\n"), PACKAGE_NAME );
    printf( _("Type \"help\" for help.\n\n") );

    /* Create ~/.jtag */
    jtag_create_jtagdir();

    /* Parse and execute the RC file */
    go = jtag_parse_rc();

    if (go) {
        /* Load history */
        jtag_load_history();

        /* main loop */
        jtag_readline_loop( "jtag> " );

        /* Save history */
        jtag_save_history();
    }

    cleanup();

    return 0;
}
Пример #6
0
int
main( int argc, char *const argv[] )
{
	int go = 0;
	int i;
	int c;
	int norc = 0;
	int help = 0;
	int version = 0;
	int quiet = 0;
	chain_t *chain = NULL;

	jtag_argv0 = argv[0];

	if(geteuid()==0 && getuid()!=0)
	{
		printf (_("'%s' must not be run suid root!\n"), "jtag");
		return(-1);
	}

#ifdef ENABLE_NLS
	/* l10n support */
	setlocale( LC_ALL, "" );
	bindtextdomain( PACKAGE, LOCALEDIR );
	textdomain( PACKAGE );
#endif /* ENABLE_NLS */

	while (1)
	{
		static struct option long_options[] =
		{
			{"version", no_argument,      0, 'v'},
			{"norc",    no_argument,      0, 'n'},
			{"interactive", no_argument,  0, 'i'},
			{"help",    no_argument,      0, 'h'},
			{"quiet",   no_argument,      0, 'q'},
			{0, 0, 0, 0}
		};

		/* `getopt_long' stores the option index here. */
		int option_index = 0;

		c = getopt_long (argc, argv, "vnhiq",
		long_options, &option_index);

		/* Detect the end of the options. */
		if (c == -1)
			break;

		switch (c)
		{
		case 'v':
			version = 1;
			break;

		case 'n':
			norc = 1;
			break;

		case 'i':
			interactive = 1;
			break;

		case 'h':
		default:
			help = 1;
			break;

		case 'q':
			quiet = 1;
			break;
		}
	}

	if (help)
	{
		/* Print help info and exit.  */
		printf (_("%s #%s\n"), PACKAGE_STRING, SVN_REVISION);
		printf ("\n");

		printf (_("Usage: %s [OPTIONS] [FILE [FILE ... ]] \n"), "jtag");
		printf ("\n");

		printf (_("  -h, --help          display this help and exit\n"));
		printf (_("  -v, --version       display version information and exit\n"));
		printf ("\n");
		printf (_("  -n, --norc          disable reading ~/.jtag/rc on startup\n"));
		printf (_("  -i, --interactive   enter interactive mode after reading files\n"));
		printf (_("  -q, --quiet         Do not print help on startup\n"));
		printf ("\n");
		printf (_("  [FILE]              file containing commands to execute\n"));
		printf ("\n");

		printf (_("  Please report bugs at http://www.urjtag.org\n"));

		exit(0);
	}

	if (version)
	{
		printf(_("\n%s #%s\n\n"
          "Copyright (C) 2002, 2003 ETC s.r.o.\n"
          "Copyright (C) 2007, 2008, 2009 Kolja Waschk and the respective authors\n"
         ), PACKAGE_STRING, SVN_REVISION);

		printf(_("\n"
		"This program is free software; you can redistribute it and/or modify\n"
		"it under the terms of the GNU General Public License as published by\n"
		"the Free Software Foundation; either version 2 of the License, or\n"
		"(at your option) any later version.\n"
		"\n"
		"This program is distributed in the hope that it will be useful,\n"
		"but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
		"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n"
		"GNU General Public License for more details.\n"
		"\n"
		"You should have received a copy of the GNU General Public License\n"
		"along with this program; if not, write to the Free Software\n"
		"Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\n"));

		exit(0);
	}

	/* input from files */
	if (argc > optind) {
		for (i = optind; i < argc; i++) {
			chain = chain_alloc();
			if (!chain) {
				printf( _("Out of memory\n") );
				return -1;
			}

			go = jtag_parse_file( chain, argv[i] );
			cleanup( chain );
			if (go < 0) {
				printf( _("Unable to open file `%s'!\n"), argv[i] );
				break;
			}
		}

		if(!interactive) return 0;
	}

	/* input from stdin */
	if (!isatty(0)) {
		chain = chain_alloc();
		if (!chain) {
			printf( _("Out of memory\n") );
			return -1;
		}
		jtag_parse_stream( chain, stdin );

		cleanup( chain );

		return 0;
	}

	/* interactive */
	if (!quiet)
		printf(
			_("\n%s #%s\n"
			"Copyright (C) 2002, 2003 ETC s.r.o.\n"
			"Copyright (C) 2007, 2008, 2009 Kolja Waschk and the respective authors\n\n"
			"%s is free software, covered by the GNU General Public License, and you are\n"
			"welcome to change it and/or distribute copies of it under certain conditions.\n"
			"There is absolutely no warranty for %s.\n\n"), PACKAGE_STRING, SVN_REVISION,
			PACKAGE_NAME, PACKAGE_NAME
		);

	chain = chain_alloc();
	if (!chain) {
		printf( _("Out of memory\n") );
		return -1;
	}

	if (!quiet) {
		printf( _("WARNING: %s may damage your hardware!\n"), PACKAGE_NAME );
		printf( _("Type \"quit\" to exit, \"help\" for help.\n\n") );
	}

	/* Create ~/.jtag */
	jtag_create_jtagdir();

	/* Parse and execute the RC file */
	go = norc ? 1 : jtag_parse_rc( chain );

#ifdef HAVE_LIBREADLINE
#ifdef HAVE_READLINE_COMPLETION
	rl_attempted_completion_function = cmd_completion;
#endif
#endif

	if (go) {

#ifdef HAVE_READLINE_HISTORY
		/* Load history */
		jtag_load_history();
#endif

		/* main loop */
		jtag_readline_loop( chain, getenv("JTAG_PROMPT") ? : "jtag> " );

#ifdef HAVE_READLINE_HISTORY
		/* Save history */
		jtag_save_history();
#endif
	}

	cleanup( chain );

	return 0;
}