コード例 #1
0
ファイル: ecard.c プロジェクト: Antonio-Zhou/Linux-2.6.11
int ecard_readchunk(struct in_chunk_dir *cd, ecard_t *ec, int id, int num)
{
	struct ex_chunk_dir excd;
	int index = 16;
	int useld = 0;

	if (!ec->cid.cd)
		return 0;

	while(1) {
		ecard_readbytes(&excd, ec, index, 8, useld);
		index += 8;
		if (c_id(&excd) == 0) {
			if (!useld && ec->loader) {
				useld = 1;
				index = 0;
				continue;
			}
			return 0;
		}
		if (c_id(&excd) == 0xf0) { /* link */
			index = c_start(&excd);
			continue;
		}
		if (c_id(&excd) == 0x80) { /* loader */
			if (!ec->loader) {
				ec->loader = (loader_t)kmalloc(c_len(&excd),
							       GFP_KERNEL);
				if (ec->loader)
					ecard_readbytes(ec->loader, ec,
							(int)c_start(&excd),
							c_len(&excd), useld);
				else
					return 0;
			}
			continue;
		}
		if (c_id(&excd) == id && num-- == 0)
			break;
	}

	if (c_id(&excd) & 0x80) {
		switch (c_id(&excd) & 0x70) {
		case 0x70:
			ecard_readbytes((unsigned char *)excd.d.string, ec,
					(int)c_start(&excd), c_len(&excd),
					useld);
			break;
		case 0x00:
			break;
		}
	}
	cd->start_offset = c_start(&excd);
	memcpy(cd->d.string, excd.d.string, 256);
	return 1;
}
コード例 #2
0
void Normal_World(void)
{
	/*while(1)
	{
		semi_write0("[Fast Model] This is normal world\n");
		asm volatile(
				".arch_extension sec\n\t"
				"smc #0\n\t") ;
	}*/

	semi_write0("[bootwrapper] Dongli Boot Kernel!\n");
	c_start();
}
コード例 #3
0
static void *c_next(struct seq_file *m, void *v, loff_t *pos)
{
	(*pos)++;
	return c_start(m, pos);
}
コード例 #4
0
ファイル: write.cpp プロジェクト: gbiggs/tawara
int main(int argc, char** argv)
{
    if (argc != 2)
    {
        std::cerr << "Usage: " << argv[0] << " <file name>\n";
        return 1;
    }

    // Open a new file and write the EBML Header. This specifies that the file
    // is an EBML file, and is a Tawara document.
    std::fstream stream(argv[1], std::ios::in|std::ios::out|std::ios::trunc);
    tawara::EBMLElement ebml_el;
    ebml_el.write(stream);

    // Open a new segment in the file. This will write some initial meta-data
    // and place some padding at the start of the file for final meta-data to
    // be written after tracks, clusters, etc. have been written.
    tawara::Segment segment;
    segment.write(stream);
    // Set up the segment information so it can be used while writing tracks
    // and clusters.
    // A UID is not required, but is highly recommended.
    boost::uuids::random_generator gen;
    boost::uuids::uuid uuid = gen();
    std::vector<char> uuid_data(uuid.size());
    std::copy(uuid.begin(), uuid.end(), uuid_data.begin());
    segment.info.uid(uuid_data);
    // The filename can be nice to know.
    segment.info.filename(argv[1]);
    // The segment's timecode scale is possibly the most important value in the
    // segment meta-data data. Without it, timely playback of frames is not
    // possible. It has a sensible default (defined in the Tawara specification),
    // but here we set it to ten milliseconds for demonstrative purposes.
    segment.info.timecode_scale(10000000);
    // The segment's date should be set. It is the somewhat-awkward value of
    // the number of seconds since the start of the millenium. Boost::Date_Time
    // to the rescue!
    bpt::ptime basis(boost::gregorian::date(2001, 1, 1));
    bpt::ptime start(bpt::second_clock::local_time());
    bpt::time_duration td = start - basis;
    segment.info.date(td.total_seconds());
    // Let's give the segment an inspirational title.
    segment.info.title("Example segment");
    // It sometimes helps to know what created a Tawara file.
    segment.info.muxing_app("libtawara-0.1");
    segment.info.writing_app("tawara_eg_write");

    // Set up the tracks meta-data and write it to the file.
    tawara::Tracks tracks;
    // Each track is represented in the Tracks information by a TrackEntry.
    // This specifies such things as the track number, the track's UID and the
    // codec used.
    tawara::TrackEntry::Ptr track(new tawara::TrackEntry(1, 1, "string"));
    track->name("Example frames");
    track->codec_name("ASCII string");
    // Adding each level 1 element (only the first occurance, in the case of
    // clusters) to the index makes opening the file later much faster.
    segment.index.insert(std::make_pair(tracks.id(),
                segment.to_segment_offset(stream.tellp())));
    // Now we can write the Tracks element.
    tracks.insert(track);
    tracks.write(stream);

    // The data itself is stored in clusters. Each cluster contains a number of
    // blocks, with each block containing a single frame of data.  Different
    // cluster implementations are available using different optimisations.
    // Here, we use the implementation that stores all its blocks in memory
    // before writing them all to the file at once. As with the segment,
    // clusters must be opened for writing before blocks are added. Once the
    // cluster is complete, it is finalised. How many blocks each cluster
    // contains is relatively flexible: the only limitation is on the range of
    // block timecodes that can be stored. Each timecode is a signed 16-bit
    // integer, and usually blocks have timecodes that are positive, limiting
    // the range to 32767. The unit of this value is the segment's timecode
    // scale. The default timecode scale therefore gives approximately 65
    // seconds of total range, with 32 seconds being used.
    tawara::MemoryCluster cluster;
    // Again, we add the cluster to the index for faster file opening.
    segment.index.insert(std::make_pair(cluster.id(),
                segment.to_segment_offset(stream.tellp())));
    // The cluster's timecode determines the basis for the timecodes of all
    // blocks in that cluster.
    bpt::ptime c_start(bpt::second_clock::local_time());
    bpt::time_duration c_td = c_start - start;
    cluster.timecode(c_td.total_microseconds() / 10000);
    // Open the cluster for writing so we can begin adding blocks.
    cluster.write(stream);
    // Here, a few blocks are added.
    for (int ii(1); ii <= 5; ++ii)
    {
        std::string frame("frame 1");
        frame[6] = ii + '0';
        // When creating a block, the track number must be specified. In our
        // case, all blocks belong to track 1. A timecode must also be given.
        // It is an offset from the cluster's timecode measured in the
        // segment's timecode scale.
        bpt::ptime b_start(bpt::second_clock::local_time());
        bpt::time_duration b_td = b_start - c_start;
        tawara::BlockElement::Ptr block(new tawara::SimpleBlock(1,
                    b_td.total_microseconds() / 10000));
        // Here the frame data itself is added to the block
        tawara::Block::FramePtr frame_ptr(
            new tawara::Block::Frame(frame.begin(), frame.end()));
        block->push_back(frame_ptr);
        // And then the block is added to its cluster.
        cluster.push_back(block);
    }
    // Finally, now that all blocks have been added, the cluster is finalised.
    cluster.finalise(stream);

    // Now we'll add another cluster, this time using the in-file cluster
    // implementation.
    tawara::FileCluster cluster2;
    // This cluster does not need to be added to the index, as it is easily
    // found during reading by skipping past the first cluster.
    // Give the cluster a timecode.
    c_start = bpt::second_clock::local_time();
    c_td = c_start - start;
    cluster2.timecode(c_td.total_microseconds() / 10000);
    // Open the cluster for writing.
    cluster2.write(stream);
    // Add some blocks.
    for (int ii(0); ii < 10; ++ii)
    {
        std::string frame("frame a");
        frame[6] = ii + 'a';
        // The block's timecode
        bpt::ptime b_start(bpt::second_clock::local_time());
        bpt::time_duration b_td = b_start - c_start;
        tawara::BlockElement::Ptr block(new tawara::SimpleBlock(1,
                    b_td.total_microseconds() / 10000));
        // Add the frame data to the block.
        tawara::Block::FramePtr frame_ptr(
            new tawara::Block::Frame(frame.begin(), frame.end()));
        block->push_back(frame_ptr);
        // Add the block to the cluster.
        cluster2.push_back(block);
    }
    // Finally, now that all blocks have been added, the cluster is finalised.
    cluster2.finalise(stream);

    // Now that all the data has been written, the last thing to do is to
    // finalise the segment.
    segment.finalise(stream);
    // And close the file.
    stream.close();

    return 0;
}