Example #1
0
void kdebug_x86_bts (void)
{
    char c;

    c = kdebug_get_choice ("\nBranch Trace Store", "Enable/Disable/Show", 's');
    switch (c)
    {
    case 'e':
	bufmng.bts_base = bufmng.bts_base;
	bufmng.bts_index = bufmng.bts_base;
	bufmng.bts_maximum = bufmng.bts_base + BTS_SIZE;
	zero_memory ((ptr_t) bufmng.bts_base, BTS_BUFSIZE);
	x86_debugctl_state |= (1<<3) + (1<<2); /* BTS + TR */
	break;

    case 'd':
	x86_debugctl_state &= ~((1<<3) + (1<<2));
	break;

    case 's':
	branch_trace_t *bt = bufmng.bts_index;
	for (int i = BTS_SIZE-1; i >= 0; i--)
	{
	    if (bt->from != bt->to)
		printf ("%4d: %c %p -> %p\n", i,
			bt->flags.predicted ? 'P' : ' ', bt->from, bt->to);
	    if (bt++ == bufmng.bts_maximum)
		bt = bufmng.bts_base;
	}
	break;
    }
}
Example #2
0
/* post processing (e.g., flushing page-table entries) */
void init_arch_3()
{

#if defined(CONFIG_DEBUG_TRACE_INIT)
    printf("CPU features: %x\n", get_cpu_features());
#endif

#if defined(CONFIG_SMP)
    /* init_arch_3 is only executed by the boot cpu */
    boot_cpu = get_apic_cpu_id();

    init_cpu_local_data();
    
    smp_startup_processors();
#endif

    /* Kmem is initialized now. */
    __zero_page = kmem_alloc(PAGE_SIZE);
    zero_memory(__zero_page, PAGE_SIZE);

    /* Flush init section. */
    //kernel_ptdir[0] = 0;
    
    flush_tlb();

#if !defined(CONFIG_X86_APIC)
    /* Do not give out the timer interrupt. */
    interrupt_owner[0] = get_idle_tcb();
    interrupt_owner[2] = get_idle_tcb();
    interrupt_owner[8] = get_idle_tcb();
#endif
}
// preserves obj, destroys len_in_bytes
void C1_MacroAssembler::initialize_body(Register obj, Register len_in_bytes, int hdr_size_in_bytes, Register t1) {
    assert(hdr_size_in_bytes >= 0, "header size must be positive or 0");
    Label done;

    // len_in_bytes is positive and ptr sized
    subptr(len_in_bytes, hdr_size_in_bytes);
    jcc(Assembler::zero, done);
    zero_memory(obj, len_in_bytes, hdr_size_in_bytes, t1);
    bind(done);
}
/*
 * Read vec in a newly allocated buffer in reverse order.
 */
static fftw_complex *alloc_reverse_from_vec(size_t size, const fftw_complex *vec) {

    fftw_complex *ret = alloc_complex(size);
    fftw_complex *tmp = ret;
    zero_memory(size, ret);

    while(size--) *tmp++ = vec[size + 1];

    return ret;
}
int main(void) {
    char *** test = alloc_memory(16,32);
    
    while(1){
        zero_memory(16,32,test);
        initialize_random(16,32,test); 
        mutate(16,32,test);
        print_memory(16,32,test);
    }
	
}
/*
 * Invert a toeplitz matrix. Input is the first column of the matrix and also
 * is the output.
 * IMP - size must be a power of two.
 */
void serial_matrix_inversion(size_t size, const fftw_complex *input, fftw_complex *result) {

    if(size < 1) return;

    //base case
    result[0] = 1 / input[0];
    if(size < 2) return;
    result[1] = - result[0] * input[1] * result[0];


    unsigned int current_size = 2;

    while(current_size < size) {

        fftw_complex *reversed_input = alloc_reverse_from_vec(current_size * 2 - 1, input);

        fftw_complex *temporary = alloc_complex(current_size);


        //first convolution
        toeplitz_mult(current_size, reversed_input, result, temporary);


        fftw_complex *reversed_inverted_pad = alloc_complex(current_size * 2 - 1);
        zero_memory(current_size * 2 - 1, reversed_inverted_pad);

        memcpy(reversed_inverted_pad + (current_size-1), result,
               current_size * sizeof(fftw_complex));

        reverse_vec(current_size * 2 - 1, reversed_inverted_pad);


        //second convolution
        reverse_vec(current_size, temporary);
        toeplitz_mult(current_size, reversed_inverted_pad, temporary, reversed_input);

        //complement sign
        for(int i=0; i < current_size; i++)
            reversed_input[i] = - reversed_input[i];

        reverse_vec(current_size, reversed_input);

        //finally copy in result vec
        memcpy(result + current_size, reversed_input, current_size * sizeof(fftw_complex));


        fftw_free(temporary);
        fftw_free(reversed_input);
        fftw_free(reversed_inverted_pad);
        current_size *= 2;
    }
}
Example #7
0
	void overlay::init_sampler()
	{
		D3D11_SAMPLER_DESC desc;
		zero_memory(desc);

		desc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
		desc.AddressU = D3D11_TEXTURE_ADDRESS_WRAP;
		desc.AddressV = D3D11_TEXTURE_ADDRESS_WRAP;
		desc.AddressW = D3D11_TEXTURE_ADDRESS_WRAP;
		desc.MaxAnisotropy = 1;
		desc.ComparisonFunc = D3D11_COMPARISON_ALWAYS;
		desc.MaxLOD = D3D11_FLOAT32_MAX;

		d3d_device::instance()->raw()->CreateSamplerState(&desc, &sampler_state);
	}
Example #8
0
//初始化队列
int    init_quene(void){
	if(quene != NULL)
	{
		printf("队列非空\n");
		return -1;
	}
	//分配队列内存
	quene = (QUENE*)malloc(sizeof(QUENE));
	if(quene == NULL)
	{
		printf("内存分配失败\n");
		return -2;
	}
	zero_memory(quene->date,sizeof(char)*MAX_LENGTH);
	quene->next = NULL;
	return 0;
}
Example #9
0
	void overlay::init_buffers(int window_width, int window_height)
	{
		D3D11_BUFFER_DESC vertex_desc, index_desc, const_desc;
		D3D11_SUBRESOURCE_DATA vertex_data, index_data;

		std::array<overlay::vertex_t, 6> vertices;
		std::array<uint32_t, 6> indices;

		zero_memory(vertex_desc);
		zero_memory(index_desc);
		zero_memory(const_desc);
		zero_memory(vertex_data);
		zero_memory(index_data);
		zero_memory(vertices);

		auto device = d3d_device::instance()->raw();
		auto context = d3d_device::instance()->get_context();

		for (uint32_t i = 0; i < vertex_count; i++)
			indices[i] = i;

		vertex_desc.Usage = D3D11_USAGE_DYNAMIC;
		vertex_desc.ByteWidth = sizeof(overlay::vertex_t) * vertex_count;
		vertex_desc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
		vertex_desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
		vertex_data.pSysMem = vertices.data();

		index_desc.ByteWidth = sizeof(uint32_t) * vertex_count;
		index_desc.BindFlags = D3D11_BIND_INDEX_BUFFER;
		index_data.pSysMem = indices.data();

		const_desc.ByteWidth = sizeof(overlay::matrix_t);
		const_desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;

		device->CreateBuffer(&vertex_desc, &vertex_data, &vertex_buffer);
		device->CreateBuffer(&index_desc, &index_data, &index_buffer);
		device->CreateBuffer(&const_desc, nullptr, &const_buffer);

		overlay::matrix_t matrix_buffer;

		cxmatrix world = XMMatrixIdentity();
		cxmatrix view = XMMatrixLookAtLH(XMVectorZero(), XMVectorSet(0.f, 0.f, 1.f, 0.f), XMVectorSet(0.f, 1.f, 0.f, 0.f));
		cxmatrix ortho = XMMatrixOrthographicLH(static_cast<float>(window_width), static_cast<float>(window_height), 0.1f, 1000.f);

		XMStoreFloat4x4(&matrix_buffer.world, XMMatrixTranspose(world));
		XMStoreFloat4x4(&matrix_buffer.view, XMMatrixTranspose(view));
		XMStoreFloat4x4(&matrix_buffer.ortho, XMMatrixTranspose(ortho));

		context->UpdateSubresource(const_buffer.Get(), 0, nullptr, &matrix_buffer, 0, 0);
	}
Example #10
0
void setup_cormon_stats(char *filename, RUN *run)
{

    log_entry("setup_cormon_stats");

    if (!SDDS_cormon_initialized) {
        SDDS_cormon_initialized = 1;
        zero_memory(&SDDS_cormon, sizeof(SDDS_cormon));
        }
    if (!filename)
        bombElegant("NULL filename passed (setup_cormon_stats)", NULL);
    if (!run)
        bombElegant("NULL RUN pointer passed (setup_cormon_stats)", NULL);

    SDDS_ElegantOutputSetup(&SDDS_cormon, filename, SDDS_BINARY, 1, "corrector/monitor statistics", run->runfile,
                            run->lattice, parameter_definition, N_PARAMETERS,
                            column_definition, N_COLUMNS, "setup_cormon_stats",
                            SDDS_EOS_NEWFILE|SDDS_EOS_COMPLETE);

    log_exit("setup_cormon_stats");
    }
void C1_MacroAssembler::initialize_body(Register base, Register index) {
  zero_memory(base, index);
}