示例#1
0
/* get kernel elf map */
static int get_kernel_map(unsigned int *base, unsigned int *limit)
{
    struct boot_params bp;
    get_boot_params(&bp);
    Elf32_Ehdr *elf_header = (Elf32_Ehdr *)(bp.kernel_addr);

    return get_elf_map(bp.kernel_addr, elf_header, base, limit);
}
示例#2
0
文件: main.c 项目: helloKM/OSDesign
/**
 * Do some initialization work.
 * 
 *****************************************************************************/
PRIVATE void init_mm()
{
	struct boot_params bp;
	get_boot_params(&bp);

	memory_size = bp.mem_size;

	/* print memory size */
	printl("{MM} Mem size:%dMB\n", memory_size / (1024 * 1024));
}
示例#3
0
/*======================================================================*
kernel_main
*======================================================================*/
PUBLIC int kernel_main()
{
	Init8259A();
	Init8253();
	SetIRQ();
	
	k_reenter = -1;
	ticks = 0;
	get_boot_params(&BootParam);
	GetCurrentTime(&systime);			//?áè?RTCê±??

	int i, j, eflags, prio;
        u8  rpl;
        u8  priv; 

	TASK * t;
	PROCESS * p = proc_table;

	char * stk = task_stack + STACK_SIZE_TOTAL + 0x4000;

	for (i = 0; i < NR_TASKS + NR_PROCS; i++,p++,t++) {
		if (i >= NR_TASKS + NR_NATIVE_PROCS) 
		{
			p->p_flags = FREE_SLOT;
			p->ldt_sel = SELECTOR_LDT_FIRST + (i << 3);		//空槽也要给LDT赋值否则调度任务会#GP异常
			continue;
		}

	        if (i < NR_TASKS) {     
                        t	= task_table + i;
                        priv	= PRIVILEGE_TASK;
                        rpl     = RPL_TASK;
                        eflags  = 0x1202;
			prio    = 1;
                }
                else {                  
                        t	= user_proc_table + (i - NR_TASKS);
                        priv	= PRIVILEGE_USER;
                        rpl     = RPL_USER;
                        eflags  = 0x202;	
			prio    = 1;
                }

		strcpy(p->name, t->name);	
		p->p_parent = NO_TASK;

		if (strcmp(t->name, "INIT") != 0) {
			p->ldts[INDEX_LDT_C]  = gdt[SELECTOR_KERNEL_CS >> 3];
			p->ldts[INDEX_LDT_RW] = gdt[SELECTOR_KERNEL_DS >> 3];

			
			p->ldts[INDEX_LDT_C].attr1  = DA_C   | priv << 5;
			p->ldts[INDEX_LDT_RW].attr1 = DA_DRW | priv << 5;
		}
		else {		
示例#4
0
文件: main.c 项目: BackupGGCode/lyos
/**
 * Do some initialization work.
 * 
 *****************************************************************************/
PRIVATE void init_mm()
{
	struct boot_params bp;
	get_boot_params(&bp);

	memory_size = bp.mem_size;
	kernel_addr = bp.kernel_file;
	
	printl("Memory:%dMB\n", memory_size / 1024 /1024);
	
	unsigned int k_base;
	unsigned int k_limit;
	int ret = get_kernel_map(&k_base, &k_limit);
	
	if (ret == 0)
		printl("Kernel memory: 0x%x - 0x%x(%dkB)\n",
					k_base, k_base + k_limit, k_limit/1024);
	
	/* int page_tbl_size = memory_size / 1024;
	buffer_base = (int)PAGE_TBL_BASE + page_tbl_size + (1024 * 1024);
	buffer_length = (2 * 1024 * 1024);
	init_buffer();
	
	rd_base = buffer_base + buffer_length + (256 * 1024);
	rd_length = 2 * 1024 * 1024;

	mem_start = rd_base + rd_length + (256 * 1024); */
	
	buffer_base = (unsigned char *)BUFFER_BASE;
	buffer_length = BUFFER_LENGTH;
	//init_buffer();
	
#ifdef RAMDISK
	rd_base = (unsigned char *)RAMDISK_BASE;
	rd_length = RAMDISK_LENGTH;
#endif

	mem_start = PROCS_BASE;
	free_mem_size = memory_size - mem_start;
	printl("Free memory:%dMB\n", free_mem_size / 1024 / 1024);

	paging_pages = memory_size / PAGE_SIZE;
	printl("%d pages\n", paging_pages);
}
示例#5
0
void init_mem(unsigned long start_mem, unsigned long end_mem)
{
    int tmp ;
    struct boot_params bp;
    get_boot_params(&bp);
    memory_size = bp.mem_size;
    memory_size  &= 0xfffff000;

    end_mem = (end_mem > memory_size)?end_mem:memory_size;
    start_mem = alloc_mem_map(start_mem, end_mem);
    start_mem = (start_mem & PAGE_MASK);

    PAGING_PAGES = (end_mem - start_mem) >> PAGE_SHIFT;

    struct page *p = (struct page *)((unsigned long)mem_map + sizeof(mem_map) * nr_mem_map);
    for(tmp = 0;tmp  < PAGING_PAGES;tmp++,p++)
    {
        mem_map[tmp] = *p;
        free_page(tmp);
    }

    printk("free pages = %d\n",PAGING_PAGES);
    return ;
}