Exemplo n.º 1
0
int main(int argc, char **argv) {

  long long mem_size=0;

  mem_size=1024*1024;
   
  mem_size=get_mem_size_iomem();
  printf("IOMEM:\n");
  printf("\traw:    %lld\n",mem_size);
  printf("\tpretty: ");
  print_mem(mem_size);
  mem_size=get_mem_size_stat();   
  printf("KCORE:\n");
  printf("\traw:    %lld\n",mem_size);
  printf("\tpretty: ");
  print_mem(mem_size);
  mem_size=get_mem_size_sysinfo();
  printf("SYSINFO:\n");
  printf("\traw:    %lld\n",mem_size);
  printf("\tpretty: ");
  print_mem(mem_size);   
  mem_size=get_mem_size_meminfo();   
  printf("MEMINFO:\n");
  printf("\traw:    %lld\n",mem_size);
  printf("\tpretty: ");
  print_mem(mem_size);   
  mem_size=get_mem_size();   
  printf("DEFAULT:\n");
  printf("\traw:    %lld\n",mem_size);
  printf("\tpretty: ");
  print_mem(mem_size);   

   
  return 0;
}
Exemplo n.º 2
0
void
mv64x60_board_init(void __iomem *old_base, void __iomem *new_base)
{
	mv64x60_console_baud = CPCI690_MPSC_BAUD;
	mv64x60_mpsc_clk_src = CPCI690_MPSC_CLK_SRC;
	mv64x60_mpsc_clk_freq =
		(get_mem_size() >= (1*GB)) ? 100000000 : 133333333;
}
inline message_queue::message_queue(open_or_create_t open_or_create,
                                    const char *name, 
                                    std::size_t max_num_msg, 
                                    std::size_t max_msg_size)
      //Create shared memory and execute functor atomically
   :  m_shmem(open_or_create, 
              name, 
              get_mem_size(max_msg_size, max_num_msg),
              read_write,
              static_cast<void*>(0),
              //Prepare initialization functor
              detail::initialization_func_t (max_num_msg, max_msg_size))
{}
Exemplo n.º 4
0
inline message_queue::message_queue(create_only_t create_only,
                                    const char *name, 
                                    std::size_t max_num_msg, 
                                    std::size_t max_msg_size)
      //Create shared memory and execute functor atomically
   :  m_shmem(create_only, 
              name, 
              get_mem_size(max_msg_size, max_num_msg),
              read_write,
              (void*)0,
              //Prepare initialization functor
              detail::initialization_func_t (max_num_msg, max_msg_size))
{}
Exemplo n.º 5
0
inline xsi_message_queue::xsi_message_queue(open_or_create_t open_or_create,
				    xsi_key key,
                                    std::size_t max_num_msg, 
                                    std::size_t max_msg_size,
                                    const permissions &perm)
      //Create shared memory and execute functor atomically
   :  m_shmem(open_or_create, 
              key, 
              get_mem_size(max_msg_size, max_num_msg),
              read_write,
              static_cast<void*>(0),
              //Prepare initialization functor
              detail::initialization_func_t (max_num_msg, max_msg_size),
              perm)
{}
Exemplo n.º 6
0
static void start(class_handle_t handle, u8 *p_mem,
  u32 size, BOOL dynamic, u8 filter_num, u8 sec_num)
{
  dvb_t *p_this = handle;
  dvb_priv_t *p_priv = p_this->p_data;
  svc_container_t *p_container = p_priv->p_container;
  u8 *p_temp = p_mem;
  u16 i = 0;
  //u32 buf_size = 0;
  u32 pti_buf_size = 0;
  u32 total_size = 0;

  p_container->lock(p_container);
  total_size = get_mem_size(handle, dynamic, filter_num, sec_num);

  MT_ASSERT(((u32)p_mem) % 4 == 0);//align 4
  MT_ASSERT((p_mem != NULL) && (size >= total_size));
  MT_ASSERT(NULL == p_priv->p_sec);

  p_priv->p_sec = (dvb_section_t *)p_temp;
  p_temp += sec_num * sizeof(dvb_section_t);
  memset(p_priv->p_sec, 0, sizeof(dvb_section_t) * sec_num);

  //create free queue
  p_priv->free_queue = create_simple_queue1(p_priv->q_handle,
    sec_num);

  for(i = 0; i < sec_num; i ++)
  {
    p_priv->p_sec[i].id = i;
    push_simple_queue(p_priv->q_handle, p_priv->free_queue, i);
  }

  //attach request buffer
  memset(p_temp, 0, DVB_ATTACH_SIZE(sec_num));
  mtos_messageq_attach(p_container->get_msgq_id(p_container),
    p_temp, sizeof(dvb_request_t), sec_num);

  p_temp += DVB_ATTACH_SIZE(sec_num);
  pti_dev_get_mem_request(p_priv->p_pti_dev, dynamic,
    filter_num, &pti_buf_size);
  pti_dev_parser_init(p_priv->p_pti_dev, dynamic,
    filter_num, p_temp, pti_buf_size);

  p_priv->dvb_actived = TRUE;

  p_container->unlock(p_container);
}
Exemplo n.º 7
0
guint8* retro_core_get_memory (RetroCore* self, RetroMemoryType id, int* length) {
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (length != NULL, NULL);

	retro_core_push_cb_data (self);

	RetroModule* module = self->module;

	RetroGetMemoryData get_mem_data = retro_module_get_get_memory_data (module);
	RetroGetMemorySize get_mem_size = retro_module_get_get_memory_size (module);

	guint8* data = get_mem_data (id);
	gsize size = get_mem_size (id);

	retro_core_pop_cb_data ();

	data = g_memdup (data, size);
	*length = (gint) (data ? size : 0);

	return data;
}
Exemplo n.º 8
0
int mem_test()
{
    #if 0
    _mem_init();
    
    MEM_T *mem = _mem_alloc(32*1024);
    if(mem)
    {
        LOG_INFO("mem->size = %d",mem->size);
        LOG_INFO("mem->phy_addr = %x",mem->phy_addr);
        LOG_INFO("mem->vir_addr = %p",mem->vir_addr);

        _mem_free(mem);
        return 0;
    }
    else
    {
        return -1;
    }
    #else
    mem_init();
    int phy_addr = 0;
    int mem_size = 0;
    void *vir_addr = NULL;
    void *ptr = mem_alloc(64*1024);
    memset(ptr,0,64*1024);
    if(ptr)
    {
        LOG_INFO("ptr is %p\n",ptr);
        vir_addr = ptr - 0x8;
        LOG_INFO("hisi vir_addr is %p\n",vir_addr);
        phy_addr = get_hisi_phy_from_ptr(ptr);
        LOG_INFO("phy_addr is %x\n",phy_addr);
        mem_size = get_mem_size(ptr);
        LOG_INFO("mem_size is %d\n",mem_size);
        mem_free(ptr);
    }
    return 0;
    #endif
}
Exemplo n.º 9
0
int add_new_mem(size_t size)
{
        void *addr;
        MM_node *new_node;

        size = get_mem_size(size) + NODE_HEADER_SIZE;

        if ((addr = mmap(NULL, size, MMAP_PROT, MMAP_FLAGS, -1, 0)) == MAP_FAILED)
        {
                return ERROR;
        }
        else
        {
                new_node = construct_node(addr);
                new_node->status = FREE;
                new_node->size = size;
                append_node(new_node);
                malloc_tail = new_node;

                return SUCCESS;
        }
}
Exemplo n.º 10
0
/*
 * Initializes malloc_head / tail from first call to malloc.
 * Mmaps for initial memory. Returns ERROR if mmap fails.
 */
int initialize(size_t req_mem_size)
{
        void *addr;
        req_mem_size = get_mem_size(req_mem_size);

        if ((addr = mmap(NULL, req_mem_size, MMAP_PROT, MMAP_FLAGS, -1, 0)) == MAP_FAILED)
        {
                return ERROR;
        }
        else
        {
                malloc_head = construct_node(addr);
                // the actual first node, so malloc_head will always point to a 'free node'
                malloc_tail = construct_node(addr + NODE_HEADER_SIZE);
                malloc_head->next_free = malloc_tail;
                malloc_head->size = 0;
                malloc_tail->next_free = NULL;
                malloc_tail->size = req_mem_size - 2 * NODE_HEADER_SIZE;

                return SUCCESS;
        }
}
Exemplo n.º 11
0
/**
 * Prints memory info
 */
void print_meminfo() {
    printk("Total mem: %d MB\nFree mem: %d MB\n", get_mem_size() / 1024, (get_max_blocks() - get_used_blocks()) * 4 / 1024);
    printk("Heap size: %d KB Free heap: %d KB\n", get_heap_size() / 1024, (get_heap_size() - get_used_heap()) / 1024);
    printk("cr0: %x cr2: %x cr3: %x\n", get_cr0(), get_cr2(), get_pdbr());
}
Exemplo n.º 12
0
static void start(class_handle_t handle, u8 *p_mem,
  u32 size, BOOL dynamic, u8 filter_num, u8 sec_num)
{
  dvb_t *p_this = handle;
  dvb_priv_t *p_priv = p_this->p_data;
  svc_container_t *p_container = p_priv->p_container;
  u8 *p_temp = NULL;
  u16 i = 0;
  //u32 buf_size = 0;
  //u32 pti_buf_size = 0;
  u32 total_size = 0;

  p_container->lock(p_container);
  total_size = get_mem_size(handle, FALSE, filter_num,sec_num);

  MT_ASSERT((p_mem != NULL) && (size >= total_size));
  MT_ASSERT(NULL == p_priv->p_sec);

  //p_temp = (u8 *)(((u32)p_mem + 3) & (~3)); //align 4
  p_temp = p_mem;
  p_priv->p_sec = (dvb_section_t *)p_temp;
  p_temp += DVB_MAX_SECTION_NUM * sizeof(dvb_section_t);
  memset(p_priv->p_sec, 0, sizeof(dvb_section_t) * DVB_MAX_SECTION_NUM);

  //create free queue
  p_priv->free_queue = create_simple_queue1(p_priv->q_handle,
    DVB_MAX_SECTION_NUM);

  for(i = 0; i < DVB_MAX_SECTION_NUM; i ++)
  {
    p_priv->p_sec[i].id = i;
    p_priv->p_sec[i].buf_id = 0xffff;
    p_priv->p_sec[i].ts_in = p_priv->main_ts_in;
    push_simple_queue(p_priv->q_handle, p_priv->free_queue, i);
  }

  //create free data buffer queue
  p_priv->free_buffer_queue = create_simple_queue1(p_priv->q_handle,
    DMX_HW_FILTER_SUM);

  for(i = 0; i < DMX_HW_FILTER_SUM; i ++)
  {
    push_simple_queue(p_priv->q_handle, p_priv->free_buffer_queue, i);
  }

  p_priv->using_buffer_queue = create_simple_queue1(p_priv->q_handle,
    DMX_HW_FILTER_SUM);

  //attach request buffer
  memset(p_temp, 0, DVB_ATTACH_SIZE);
  mtos_messageq_attach(p_container->get_msgq_id(p_container),
    p_temp, sizeof(dvb_request_t), DVB_MSG_DEPTH);

  p_temp += DVB_ATTACH_SIZE;
  p_temp = (u8 *)(((u32)p_temp + 7) & (~7)); //align 4  // 8 byte
  p_priv->p_data_buffer = p_temp;
  //pti_dev_get_mem_request(p_priv->p_pti_dev, dynamic,
    //filter_num, &pti_buf_size);
  //pti_dev_parser_init(p_priv->p_pti_dev, dynamic,
    //filter_num, p_temp, pti_buf_size);
    

  p_container->unlock(p_container);
}
Exemplo n.º 13
0
char * WINAPI vt_lstrcpynA (char *dest,char *source,int maxlen)
{
        char dbgmsg[1024];
        LPTSTR retval;

        _snprintf(dbgmsg, sizeof(dbgmsg), "[VulnTrace]: lstrcpynA(0x%08x:[%d], %s, %d)\n",dest,get_mem_size(dest), source, max-len);
        dbgmsg[sizeof(dbgmsg)-1] = 0;
        
        OutputDebugString(dbgmsg);

        retval = real_lstrcpynA(dest, source, maxlen);
        
        return(retval);
}
Exemplo n.º 14
0
int main()
{
	char bios_version[16];
	unsigned long mem_size;

	printf("86INFO v1.1, author: PING-HUI WEI, E-mail: [email protected], 2016/03/18\n");

	printf("CPU:\t\t\t ");
	switch(vx86_CpuID())
	{
		case CPU_VORTEX86SX:
			printf("Vortex86SX\n");
			break;
		case CPU_VORTEX86DX_UNKNOWN:
			printf("Vortex86DX_unknown\n");
			break;
		case CPU_VORTEX86DX_A:
			printf("Vortex86DX_A\n");
			break;
		case CPU_VORTEX86DX_C:
			printf("Vortex86DX_C\n");
			break;
		case CPU_VORTEX86DX_D:
			printf("Vortex86DX_D\n");
			break;
		case CPU_VORTEX86MX:
			printf("Vortex86MX\n");
			break;
		case CPU_VORTEX86MX_PLUS:
			printf("Vortex86MX_plus\n");
			break;
		case CPU_VORTEX86DX2:
			printf("Vortex86DX2\n");
			break;
		case CPU_VORTEX86DX3:
			printf("Vortex86DX3\n");
			break;
		case CPU_VORTEX86EX:
			printf("Vortex86EX\n");
			break;
		case CPU_UNSUPPORTED:
		default:
			printf("unsupported\n");
	}

	printf("CPU Frequency:\t\t %ldMHz\n", vx86_CpuCLK());
	printf("CPU Temperature:\t %f °C\n", cpuTemperature());

	printf("Memory Size:\t\t");
	if(get_mem_size(&mem_size) == false)
		printf("get memory size error!\n");
	else
		printf(" %luMB\n", mem_size);

	printf("Memory Frequency:\t %luMHz\n", vx86_DramCLK());

	printf("BIOS Version:\t\t");
	if(get_BIOS_version(bios_version) == false)
		printf("get bios version error!\n");
	else
		printf(" %s\n", bios_version);

	return EXIT_SUCCESS;
} 
Exemplo n.º 15
0
int compress_mem_chunk(
    const uint64_t mem_read_start, 
    const uint64_t mem_read_length, 
    const uint64_t mem_output_start, 
    uint64_t* const mem_output_length, 
    struct compress_header** const header_address)
{
    int return_code = 0;

    printf("Chunk %016" PRIx64 " - %016" PRIx64 " @ 0x%" PRIx64 " (%s)...\n", 
        mem_read_start, 
        mem_read_start + mem_read_length, 
        mem_output_start,
        get_mem_size(*mem_output_length)
    );

    unsigned char src_buffer[128];
    unsigned char dst_buffer[DST_BUFFER_SIZE];
    
    uint64_t mem_read_pointer = mem_read_start;
    uint64_t mem_output_pointer = mem_output_start;

    context_sha256_t sha256_ctx;

    z_stream stream_context;

    stream_context.zalloc = (alloc_func)0;
    stream_context.zfree = (free_func)0;
    stream_context.opaque = (voidpf)0;

    stream_context.next_out = dst_buffer;
    stream_context.avail_out = DST_BUFFER_SIZE;

    if (deflateInit(&stream_context, Z_BEST_COMPRESSION) != Z_OK) {
        printf("Zlib init failed!\n");
        return RETURN_CODE_FAILED;
    }

    sha256_starts(&sha256_ctx);

    // Set header pointer to begin of the output buffer
    *header_address = (struct compress_header*) mem_output_pointer;
    mem_output_pointer += sizeof(struct compress_header);

    uint64_t bytes_read = 0;
    uint64_t bytes_write = 0;
    uint64_t bytes_skipped = 0;

    for (; 
        mem_read_pointer < mem_read_start + mem_read_length && 
        mem_output_pointer + DST_BUFFER_SIZE < mem_output_start + *mem_output_length && 
        IS_VALID_POINTER(mem_read_pointer);
        mem_read_pointer += sizeof(int)) 
    {
        bool buffer_underrun = 0;
        int data;

        if (stream_context.avail_out < 100) {
            // We have less than 100 bytes in our scratchpad...
            // There are basicly 2 options left. Skip some data or crash.
            // Most likely is skipping some data the less evil of the two

            if (!buffer_underrun) {
                printf("WARNING: Buffer underrun!\n");

                buffer_underrun = 1;
            }

            data = 0;

            bytes_skipped += sizeof(int);            
        }
        else if (is_readable_mem_address(mem_read_pointer)) {
            data = *((int*)mem_read_pointer);

            bytes_read += sizeof(int);

            buffer_underrun = 0;
        }
        else {
            data = 0;

            bytes_skipped += sizeof(int);
        }

        sha256_update(&sha256_ctx, (uint8_t*)&data, sizeof(int));

        //The input is not always 100% used, so use a small buffer for the few cases a couple of bytes are left
        *(int*)(src_buffer + stream_context.avail_in) = data;

        stream_context.next_in = src_buffer;
        stream_context.avail_in += sizeof(int);

        if (deflate(&stream_context, Z_NO_FLUSH) != Z_OK) {
            printf("Memory compression failed!\n");
            
            return_code = RETURN_CODE_FAILED;
            goto out;
        }

        if (stream_context.avail_out < (DST_BUFFER_SIZE - 100)) {
            unsigned short bytes_waiting = DST_BUFFER_SIZE - stream_context.avail_out;

            if ((mem_output_pointer + bytes_waiting) < mem_read_pointer || mem_read_start + mem_read_length <= mem_output_start) { 
                // Make sure we stay behind the read pointer
                uint64_t mem_output_length_remaing = *mem_output_length - (mem_output_pointer - mem_output_start);

                if (write_buffer_to_buffer(dst_buffer, bytes_waiting, mem_output_pointer, &mem_output_length_remaing) < 0 || 
                    mem_output_length_remaing == 0)
                {
                    printf("Fatal error!\n");
                    
                    return_code = RETURN_CODE_FAILED;
                    goto out;
                }

                mem_output_pointer += mem_output_length_remaing;
                bytes_write += bytes_waiting;

                stream_context.next_out = dst_buffer;
                stream_context.avail_out = DST_BUFFER_SIZE;
            }
        }

        if (stream_context.avail_out == 0) {
            printf("Memory compression failed! No space left in buffer\n");
            printf("Read pointer %016" PRIx64 " Output pointer %016" PRIx64 " length %x\n", 
                mem_read_pointer, 
                mem_output_pointer, 
                (DST_BUFFER_SIZE - stream_context.avail_out)
            );
            
            return_code = RETURN_CODE_FAILED;
            goto out;
        }
    }

    if (IS_32BIT() && mem_read_pointer > ~0u) {
        printf("WARNING: Only lower 32 bit of memory is compressed!\n");
    }

    int deflate_status;
    do {
        deflate_status = deflate(&stream_context, Z_FINISH);

        if (deflate_status != Z_OK && deflate_status != Z_STREAM_END) {
            printf("Memory compression failed to finish!\n");
            
            return_code = RETURN_CODE_FAILED;
            goto out;
        }

        unsigned short bytes_waiting = DST_BUFFER_SIZE - stream_context.avail_out;

        if ((mem_output_pointer + bytes_waiting) >= mem_read_pointer && mem_output_start <= mem_read_start) {
            printf("WARNING: Output buffer will overwrite not read data!\n");
            printf("Read pointer %016" PRIx64 " Output pointer %016" PRIx64 " length %x\n", 
                mem_read_pointer, 
                mem_output_pointer, 
                (DST_BUFFER_SIZE - stream_context.avail_out)
            );
            
            return_code = RETURN_CODE_FAILED;
            goto out;
        }

        uint64_t mem_output_length_remaing = *mem_output_length - (mem_output_pointer - mem_output_start);

        if (write_buffer_to_buffer(dst_buffer, bytes_waiting, mem_output_pointer, &mem_output_length_remaing) < 0 || 
            mem_output_length_remaing == 0)
        {
            printf("Fatal error!\n");
            
            return_code = RETURN_CODE_FAILED;
            goto out;
        }

        mem_output_pointer += mem_output_length_remaing;
        bytes_write += bytes_waiting;

        stream_context.next_out = dst_buffer;
        stream_context.avail_out = DST_BUFFER_SIZE;
    }
    while(deflate_status == Z_OK);

    if (deflateEnd(&stream_context) != Z_OK) {
        printf("Compression state failure!\n");
        
        return_code = RETURN_CODE_FAILED;
        goto out;
    }

out:

    //Marker so it can be found back
    (*header_address)->marker[0] = 'M';
    (*header_address)->marker[1] = 'E';
    (*header_address)->marker[2] = 'M';
    (*header_address)->marker[3] = 0xf1;
    (*header_address)->marker[4] = 0x88;
    (*header_address)->marker[5] = 0x15;
    (*header_address)->marker[6] = 0x08;
    (*header_address)->marker[7] = 0x5c;

    (*header_address)->start_address = mem_read_start;
    (*header_address)->end_address = mem_read_pointer - 1;
    (*header_address)->compressed_length = bytes_write;
    (*header_address)->uncompressed_length = bytes_read + bytes_skipped;
    (*header_address)->skipped_length = bytes_skipped;

    sha256_finish(&sha256_ctx, (*header_address)->checksum);

    *mem_output_length = mem_output_pointer - mem_output_start;

    g_chunks++;

    return return_code;
}
Exemplo n.º 16
0
Arquivo: misc.c Projeto: 274914765/C
struct bi_record *
decompress_kernel(unsigned long load_addr, int num_words, unsigned long cksum)
{
#ifdef INTERACTIVE_CONSOLE
    int timer = 0;
    char ch;
#endif
    char *cp;
    struct bi_record *rec;
    unsigned long initrd_loc = 0, TotalMemory = 0;

#if defined(CONFIG_SERIAL_8250_CONSOLE) || defined(CONFIG_SERIAL_MPSC_CONSOLE)
    com_port = serial_init(0, NULL);
#endif

#if defined(PPC4xx_EMAC0_MR0)
    /* Reset MAL */
    mtdcr(DCRN_MALCR(DCRN_MAL_BASE), MALCR_MMSR);
    /* Wait for reset */
    while (mfdcr(DCRN_MALCR(DCRN_MAL_BASE)) & MALCR_MMSR) {};
    /* Reset EMAC */
    *(volatile unsigned long *)PPC4xx_EMAC0_MR0 = 0x20000000;
    __asm__ __volatile__("eieio");
#endif

    /*
     * Call get_mem_size(), which is memory controller dependent,
     * and we must have the correct file linked in here.
     */
    TotalMemory = get_mem_size();

    /* assume the chunk below 8M is free */
    end_avail = (char *)0x00800000;

    /*
     * Reveal where we were loaded at and where we
     * were relocated to.
     */
    puts("loaded at:     "); puthex(load_addr);
    puts(" "); puthex((unsigned long)(load_addr + (4*num_words)));
    puts("\n");
    if ( (unsigned long)load_addr != (unsigned long)&start )
    {
        puts("relocated to:  "); puthex((unsigned long)&start);
        puts(" ");
        puthex((unsigned long)((unsigned long)&start + (4*num_words)));
        puts("\n");
    }

    /*
     * We link ourself to 0x00800000.  When we run, we relocate
     * ourselves there.  So we just need __image_begin for the
     * start. -- Tom
     */
    zimage_start = (char *)(unsigned long)(&__image_begin);
    zimage_size = (unsigned long)(&__image_end) -
            (unsigned long)(&__image_begin);

    initrd_size = (unsigned long)(&__ramdisk_end) -
        (unsigned long)(&__ramdisk_begin);

    /*
     * The zImage and initrd will be between start and _end, so they've
     * already been moved once.  We're good to go now. -- Tom
     */
    avail_ram = (char *)PAGE_ALIGN((unsigned long)_end);
    puts("zimage at:     "); puthex((unsigned long)zimage_start);
    puts(" "); puthex((unsigned long)(zimage_size+zimage_start));
    puts("\n");

    if ( initrd_size ) {
        puts("initrd at:     ");
        puthex((unsigned long)(&__ramdisk_begin));
        puts(" "); puthex((unsigned long)(&__ramdisk_end));puts("\n");
    }

#ifndef CONFIG_40x /* don't overwrite the 40x image located at 0x00400000! */
    avail_ram = (char *)0x00400000;
#endif
    end_avail = (char *)0x00800000;
    puts("avail ram:     "); puthex((unsigned long)avail_ram); puts(" ");
    puthex((unsigned long)end_avail); puts("\n");

    if (keyb_present)
        CRT_tstc();  /* Forces keyboard to be initialized */

    /* Display standard Linux/PPC boot prompt for kernel args */
    puts("\nLinux/PPC load: ");
    cp = cmd_line;
    memcpy (cmd_line, cmd_preset, sizeof(cmd_preset));
    while ( *cp ) putc(*cp++);

#ifdef INTERACTIVE_CONSOLE
    /*
     * If they have a console, allow them to edit the command line.
     * Otherwise, don't bother wasting the five seconds.
     */
    while (timer++ < 5*1000) {
        if (tstc()) {
            while ((ch = getc()) != '\n' && ch != '\r') {
                /* Test for backspace/delete */
                if (ch == '\b' || ch == '\177') {
                    if (cp != cmd_line) {
                        cp--;
                        puts("\b \b");
                    }
                /* Test for ^x/^u (and wipe the line) */
                } else if (ch == '\030' || ch == '\025') {
                    while (cp != cmd_line) {
                        cp--;
                        puts("\b \b");
                    }
                } else {
                    *cp++ = ch;
                    putc(ch);
                }
            }
            break;  /* Exit 'timer' loop */
        }
        udelay(1000);  /* 1 msec */
    }
    *cp = 0;
#endif
    puts("\n");

    puts("Uncompressing Linux...");
    gunzip(NULL, 0x400000, zimage_start, &zimage_size);
    puts("done.\n");

    /* get the bi_rec address */
    rec = bootinfo_addr(zimage_size);

    /* We need to make sure that the initrd and bi_recs do not
     * overlap. */
    if ( initrd_size ) {
        unsigned long rec_loc = (unsigned long) rec;
        initrd_loc = (unsigned long)(&__ramdisk_begin);
        /* If the bi_recs are in the middle of the current
         * initrd, move the initrd to the next MB
         * boundary. */
        if ((rec_loc > initrd_loc) &&
                ((initrd_loc + initrd_size) > rec_loc)) {
            initrd_loc = _ALIGN((unsigned long)(zimage_size)
                    + (2 << 20) - 1, (2 << 20));
             memmove((void *)initrd_loc, &__ramdisk_begin,
                 initrd_size);
                 puts("initrd moved:  "); puthex(initrd_loc);
             puts(" "); puthex(initrd_loc + initrd_size);
             puts("\n");
        }
    }

    bootinfo_init(rec);
    if ( TotalMemory )
        bootinfo_append(BI_MEMSIZE, sizeof(int), (void*)&TotalMemory);

    bootinfo_append(BI_CMD_LINE, strlen(cmd_line)+1, (void*)cmd_line);

    /* add a bi_rec for the initrd if it exists */
    if (initrd_size) {
        unsigned long initrd[2];

        initrd[0] = initrd_loc;
        initrd[1] = initrd_size;

        bootinfo_append(BI_INITRD, sizeof(initrd), &initrd);
    }
    puts("Now booting the kernel\n");
    serial_close(com_port);

    return rec;
}
Exemplo n.º 17
0
Arquivo: skbuff.c Projeto: foxwolf/yjd
struct sk_buff *__alloc_skb(const char* name, unsigned int size, gfp_t gfp_mask, int fclone, int
	node)
{
	uint32_t ret_size;
	//	struct kmem_cache *cache;
	struct skb_shared_info *shinfo;
	struct sk_buff *skb;
	u8 *data;
#if USE_MEM_DEBUG
	skb = mem_calloc_ex(name, sizeof(struct sk_buff), 1);
#else
	skb = mem_calloc(sizeof(struct sk_buff), 1);
#endif
	if (!skb)
		goto out;

	g_skb_alloc_size += get_mem_size(skb);
	
	size = SKB_DATA_ALIGN(size);
	data = mem_malloc(size + sizeof(struct skb_shared_info));

	if (!data)
		goto nodata;
	//	prefetchw(data + size);

	g_skb_alloc_size += get_mem_size(data);
	/*
	 * Only clear those fields we need to clear, not those that we will
	 * actually initialise below. Hence, don't put any more fields after
	 * the tail pointer in struct sk_buff!
	 */
	memset(skb, 0, offsetof(struct sk_buff, tail));
	skb->truesize = size + sizeof(struct sk_buff);
	atomic_set(&skb->users, 1);
	skb->head = data;
	skb->data = data;
	skb_reset_tail_pointer(skb);
	skb->end = skb->tail + size;
	#ifdef NET_SKBUFF_DATA_USES_OFFSET
	skb->mac_header = ~0U;
	#endif 
	//SET_MONITOR_ITEM_VALUE(_g_skb_alloc_size, g_skb_alloc_size);
	/* make sure we initialize shinfo sequentially */
	shinfo = skb_shinfo(skb);
	memset(shinfo, 0, /*offsetof(struct skb_shared_info, dataref)*/sizeof(struct skb_shared_info));
	atomic_set(&shinfo->dataref, 1);
	//	kmemcheck_annotate_variable(shinfo->destructor_arg);

	if (fclone)
	{
		p_err("fclone\n");
	} 
out: 
	return skb;
nodata: 
	ret_size = kmem_cache_free(cache, skb);

	g_skb_alloc_size -= ret_size;
	skb = NULL;
	goto out;
}