⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fw-emu.c

📁 这个linux源代码是很全面的~基本完整了~使用c编译的~由于时间问题我没有亲自测试~但就算用来做参考资料也是非常好的
💻 C
📖 第 1 页 / 共 2 页
字号:
}static efi_status_tefi_unimplemented (void){	return EFI_UNSUPPORTED;}static longsal_emulator (long index, unsigned long in1, unsigned long in2,	      unsigned long in3, unsigned long in4, unsigned long in5,	      unsigned long in6, unsigned long in7){	register long r9 asm ("r9") = 0;	register long r10 asm ("r10") = 0;	register long r11 asm ("r11") = 0;	long status;	/*	 * Don't do a "switch" here since that gives us code that	 * isn't self-relocatable.	 */	status = 0;	if (index == SAL_FREQ_BASE) {		switch (in1) {		      case SAL_FREQ_BASE_PLATFORM:			r9 = 200000000;			break;		      case SAL_FREQ_BASE_INTERVAL_TIMER:			/*			 * Is this supposed to be the cr.itc frequency			 * or something platform specific?  The SAL			 * doc ain't exactly clear on this...			 */			r9 = 700000000;			break;		      case SAL_FREQ_BASE_REALTIME_CLOCK:			r9 = 1;			break;		      default:			status = -1;			break;		}	} else if (index == SAL_SET_VECTORS) {		;	} else if (index == SAL_GET_STATE_INFO) {		;	} else if (index == SAL_GET_STATE_INFO_SIZE) {		;	} else if (index == SAL_CLEAR_STATE_INFO) {		;	} else if (index == SAL_MC_RENDEZ) {		;	} else if (index == SAL_MC_SET_PARAMS) {		;	} else if (index == SAL_CACHE_FLUSH) {		;	} else if (index == SAL_CACHE_INIT) {		;#ifdef CONFIG_PCI	} else if (index == SAL_PCI_CONFIG_READ) {		/*		 * in1 contains the PCI configuration address and in2		 * the size of the read.  The value that is read is		 * returned via the general register r9.		 */                outl(BUILD_CMD(in1), 0xCF8);                if (in2 == 1)                           /* Reading byte  */                        r9 = inb(0xCFC + ((REG_OFFSET(in1) & 3)));                else if (in2 == 2)                      /* Reading word  */                        r9 = inw(0xCFC + ((REG_OFFSET(in1) & 2)));                else                                    /* Reading dword */                        r9 = inl(0xCFC);                status = PCIBIOS_SUCCESSFUL;	} else if (index == SAL_PCI_CONFIG_WRITE) {	      	/*		 * in1 contains the PCI configuration address, in2 the		 * size of the write, and in3 the actual value to be		 * written out.		 */                outl(BUILD_CMD(in1), 0xCF8);                if (in2 == 1)                           /* Writing byte  */                        outb(in3, 0xCFC + ((REG_OFFSET(in1) & 3)));                else if (in2 == 2)                      /* Writing word  */                        outw(in3, 0xCFC + ((REG_OFFSET(in1) & 2)));                else                                    /* Writing dword */                        outl(in3, 0xCFC);                status = PCIBIOS_SUCCESSFUL;#endif /* CONFIG_PCI */	} else if (index == SAL_UPDATE_PAL) {		;	} else {		status = -1;	}	asm volatile ("" :: "r"(r9), "r"(r10), "r"(r11));	return status;}/* * This is here to work around a bug in egcs-1.1.1b that causes the * compiler to crash (seems like a bug in the new alias analysis code. */void *id (long addr){	return (void *) addr;}struct ia64_boot_param *sys_fw_init (const char *args, int arglen){	efi_system_table_t *efi_systab;	efi_runtime_services_t *efi_runtime;	efi_config_table_t *efi_tables;	struct ia64_sal_systab *sal_systab;	efi_memory_desc_t *efi_memmap, *md;	unsigned long *pal_desc, *sal_desc;	struct ia64_sal_desc_entry_point *sal_ed;	struct ia64_boot_param *bp;	unsigned char checksum = 0;	char *cp, *cmd_line;	int i = 0;#	define MAKE_MD(typ, attr, start, end)		\	do {						\		md = efi_memmap + i++;			\		md->type = typ;				\		md->pad = 0;				\		md->phys_addr = start;			\		md->virt_addr = 0;			\		md->num_pages = (end - start) >> 12;	\		md->attribute = attr;			\	} while (0)	memset(fw_mem, 0, sizeof(fw_mem));	pal_desc = (unsigned long *) &pal_emulator_static;	sal_desc = (unsigned long *) &sal_emulator;	cp = fw_mem;	efi_systab  = (void *) cp; cp += sizeof(*efi_systab);	efi_runtime = (void *) cp; cp += sizeof(*efi_runtime);	efi_tables  = (void *) cp; cp += sizeof(*efi_tables);	sal_systab  = (void *) cp; cp += sizeof(*sal_systab);	sal_ed      = (void *) cp; cp += sizeof(*sal_ed);	efi_memmap  = (void *) cp; cp += NUM_MEM_DESCS*sizeof(*efi_memmap);	bp	    = (void *) cp; cp += sizeof(*bp);	cmd_line    = (void *) cp;	if (args) {		if (arglen >= 1024)			arglen = 1023;		memcpy(cmd_line, args, arglen);	} else {		arglen = 0;	}	cmd_line[arglen] = '\0';	memset(efi_systab, 0, sizeof(efi_systab));	efi_systab->hdr.signature = EFI_SYSTEM_TABLE_SIGNATURE;	efi_systab->hdr.revision  = EFI_SYSTEM_TABLE_REVISION;	efi_systab->hdr.headersize = sizeof(efi_systab->hdr);	efi_systab->fw_vendor = __pa("H\0e\0w\0l\0e\0t\0t\0-\0P\0a\0c\0k\0a\0r\0d\0\0");	efi_systab->fw_revision = 1;	efi_systab->runtime = __pa(efi_runtime);	efi_systab->nr_tables = 1;	efi_systab->tables = __pa(efi_tables);	efi_runtime->hdr.signature = EFI_RUNTIME_SERVICES_SIGNATURE;	efi_runtime->hdr.revision = EFI_RUNTIME_SERVICES_REVISION;	efi_runtime->hdr.headersize = sizeof(efi_runtime->hdr);	efi_runtime->get_time = __pa(&efi_get_time);	efi_runtime->set_time = __pa(&efi_unimplemented);	efi_runtime->get_wakeup_time = __pa(&efi_unimplemented);	efi_runtime->set_wakeup_time = __pa(&efi_unimplemented);	efi_runtime->set_virtual_address_map = __pa(&efi_unimplemented);	efi_runtime->get_variable = __pa(&efi_unimplemented);	efi_runtime->get_next_variable = __pa(&efi_unimplemented);	efi_runtime->set_variable = __pa(&efi_unimplemented);	efi_runtime->get_next_high_mono_count = __pa(&efi_unimplemented);	efi_runtime->reset_system = __pa(&efi_reset_system);	efi_tables->guid = SAL_SYSTEM_TABLE_GUID;	efi_tables->table = __pa(sal_systab);	/* fill in the SAL system table: */	memcpy(sal_systab->signature, "SST_", 4);	sal_systab->size = sizeof(*sal_systab);	sal_systab->sal_rev_minor = 1;	sal_systab->sal_rev_major = 0;	sal_systab->entry_count = 1;#ifdef CONFIG_IA64_GENERIC        strcpy(sal_systab->oem_id, "Generic");        strcpy(sal_systab->product_id, "IA-64 system");#endif#ifdef CONFIG_IA64_HP_SIM	strcpy(sal_systab->oem_id, "Hewlett-Packard");	strcpy(sal_systab->product_id, "HP-simulator");#endif#ifdef CONFIG_IA64_SDV	strcpy(sal_systab->oem_id, "Intel");	strcpy(sal_systab->product_id, "SDV");#endif	/* fill in an entry point: */	sal_ed->type = SAL_DESC_ENTRY_POINT;	sal_ed->pal_proc = __pa(pal_desc[0]);	sal_ed->sal_proc = __pa(sal_desc[0]);	sal_ed->gp = __pa(sal_desc[1]);	for (cp = (char *) sal_systab; cp < (char *) efi_memmap; ++cp)		checksum += *cp;	sal_systab->checksum = -checksum;#if SIMPLE_MEMMAP	/* simulate free memory at physical address zero */	MAKE_MD(EFI_BOOT_SERVICES_DATA,		EFI_MEMORY_WB,    0*MB,    1*MB);	MAKE_MD(EFI_PAL_CODE,			EFI_MEMORY_WB,    1*MB,    2*MB);	MAKE_MD(EFI_CONVENTIONAL_MEMORY,	EFI_MEMORY_WB,    2*MB,  130*MB);	MAKE_MD(EFI_CONVENTIONAL_MEMORY,	EFI_MEMORY_WB, 4096*MB, 4128*MB);#else	MAKE_MD( 4,		   0x9, 0x0000000000000000, 0x0000000000001000);	MAKE_MD( 7,		   0x9, 0x0000000000001000, 0x000000000008a000);	MAKE_MD( 4,		   0x9, 0x000000000008a000, 0x00000000000a0000);	MAKE_MD( 5, 0x8000000000000009, 0x00000000000c0000, 0x0000000000100000);	MAKE_MD( 7,		   0x9, 0x0000000000100000, 0x0000000004400000);	MAKE_MD( 2,		   0x9, 0x0000000004400000, 0x0000000004be5000);	MAKE_MD( 7,		   0x9, 0x0000000004be5000, 0x000000007f77e000);	MAKE_MD( 6, 0x8000000000000009, 0x000000007f77e000, 0x000000007fb94000);	MAKE_MD( 6, 0x8000000000000009, 0x000000007fb94000, 0x000000007fb95000);	MAKE_MD( 6, 0x8000000000000009, 0x000000007fb95000, 0x000000007fc00000);	MAKE_MD(13, 0x8000000000000009, 0x000000007fc00000, 0x000000007fc3a000);	MAKE_MD( 7,		   0x9, 0x000000007fc3a000, 0x000000007fea0000);	MAKE_MD( 5, 0x8000000000000009, 0x000000007fea0000, 0x000000007fea8000);	MAKE_MD( 7,		   0x9, 0x000000007fea8000, 0x000000007feab000);	MAKE_MD( 5, 0x8000000000000009, 0x000000007feab000, 0x000000007ffff000);	MAKE_MD( 7,		   0x9, 0x00000000ff400000, 0x0000000104000000);#endif	bp->efi_systab = __pa(&fw_mem);	bp->efi_memmap = __pa(efi_memmap);	bp->efi_memmap_size = NUM_MEM_DESCS*sizeof(efi_memory_desc_t);	bp->efi_memdesc_size = sizeof(efi_memory_desc_t);	bp->efi_memdesc_version = 1;	bp->command_line = __pa(cmd_line);	bp->console_info.num_cols = 80;	bp->console_info.num_rows = 25;	bp->console_info.orig_x = 0;	bp->console_info.orig_y = 24;	bp->fpswa = 0;	return bp;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -