单龙芯3A3000-7A1000PMON研究学习-(10)撸起袖子干-pmoncfg Bonito 干了什么?(这是make cfg的部分)

1.前面留下了问题,第5条。

使用了pmoncfg命令,目录在 Targets/Bonito3a3000_7a/conf/中,执行命令pmoncfg Bonito

Bonito 是一个文件,但是里面只有一个包含语句:

include "Targets/Bonito3a3000_7a/conf/Bonito.3a3000_7a"

实际使用的还是 Targets/Bonito3a3000_7a/conf/Bonito.3a3000_7a这个文件,这个文件内容比较多,我先贴出来:

# $Id: Bonito,v 1.1.1.1 2006/09/14 01:59:09 root Exp $ # #    GENERIC configuration for Galileo EV64240 # #  This file is supposed to be included by target file after #  endian has been defined.
#
machine         Bonito3a3000_7a        mips    # CPU Architecture, Platform
config          pmon 
option          VGAROM_IN_BIOS
#
#  Define target endian
#
makeoptions    ENDIAN=EL        # Little endian version.


#include "conf/GENERIC_ALL"

#
# System Name and Target Name
#
option        SYSTYPE="\"Bonito\""
option        TARGETNAME="\"Bonito\""

#
# Platform options
#
option        loongson3A3
option        LSMC_2
#option        ARB_LEVEL       #use software MC leveling
option        DDR3_DIMM       #board use DDR3 memory, use: USE_SB_I2C, else use USE_GPIO_I2C and MULTI_I2C_BUS

#option        AUTO_DDR_CONFIG #use DIMM SPD auto detect DIMM
option      USE_LS2H_I2C
option      LOONGSON_GMAC
#option             LS3A7A_STR

option        BONITOEL    
option        DEVBD2F
option        LS3_SERVER
option        MIPS
option        INET
option        LS3_HT              # Enable the IO cache coherent of HT
#option        MCP68_IDE           # Enable the MCP68 IDE 0 channel
#option        USE_LPC_UART
#option        USE_SB700_LPC_UART
#option        MULTI_CHIP #for 3a3000_2w_7a
option        BOOTCORE_ID=0
#option        RESERVED_COREMASK=0xff00 #for 3a3000_2w_7a
option        RESERVED_COREMASK=0xfff0 #for 3a3000_7a
option        SHUTDOWN_MASK=0x0000
#option        LS7A_PHYS48_TO_HT40 #support 40 bit DMA device,3a3000-1w do not use it.If change bit offset should change dma rx window otherwise cause error.

option      LOONGSON_3ASINGLE #for 3a3000_7a
#option        LOONGSON_3ASERVER #for 3a3000_2w_7a
#option         LOONGSON_3A92W
option        BONITO_33M
option        BOOT_PARAM
option        LS7A            #for 7A
#select         amd_780e

#option        ENABLE_SATA         #Enable SATA  ,when enable IDE can also use, when commended only IDE can use
#option        X800x600
#option        FB_XSIZE=640
#option        FB_YSIZE=480
option        CONFIG_VIDEO_16BPP
option      X1024x768

## VGA option ##
option        SERVER_3A
#option        RS780E
#option        USE_780E_VGA
#option        USE_BMC
option        VGA_NO_ROM
option        VGA_BASE=0xbe000000
#option        VGA_BASE=0xc0000000
option        VRAM_SIZE=128
#option        DEBUG_EMU_VGA
option        AUTOLOAD
#option        INITRD_ADDR="0x9800000090000000"

#
# GPU driver selection. Selects for video
# Disable all options below to disable gpu driver 
# Enable all options below to enble gpu driver 
#
select        mod_x86emu_int10
select        mod_framebuffer
select        mod_vesa
select        mod_vgacon
#option        VESAFB
option        INTERFACE_3A780E

#
# flash type selection. Selects flash support
#
select        mod_flash_amd        # AMD flash device programming
select        mod_flash_intel        # intel flash device programming
select        mod_flash_sst        # intel flash device programming
select        mod_debugger        # Debugging module
select        mod_symbols        # Symbol table handling
select        mod_s3load        # Srecord loading
#select        mod_fastload        # LSI Fastload
select        mod_elfload        # ELF loading

#
# Command selection. Selects pmon commands
#
select          cmd_test_spi
select        cmd_newmt
select        cmd_setup
select        mod_display
select        cmd_about        # Display info about PMON
select        cmd_boot        # Boot wrapper
select        cmd_mycmd        
select        cmd_newmt
select        cmd_cache        # Cache enabling
#select        cmd_call        # Call a function command
select        cmd_date        # Time of day command
select        cmd_env            # Full blown environment command set
select        cmd_flash        # Flash programming cmds
select        cmd_hist        # Command history
select        cmd_ifaddr        # Interface address command
select        cmd_l            # Disassemble
select        cmd_mem            # Memory manipulation commands
select        cmd_more        # More paginator
select        cmd_mt            # Simple memory test command
select        cmd_misc        # Reboot & Flush etc.
#select        cmd_stty        # TTY setings command
select        cmd_tr            # Host port-through command
select        cmd_devls        # Device list
select        cmd_set            # As cmd_env but not req. cmd_hist
select        cmd_testdisk
#

select          cmd_test                # test commands,test hardisk
select        cmd_shell        # Shell commands, vers, help, eval
select        cmd_dtb
option        DTB


#
#
# Platform options
#
select        mod_uart_ns16550    # Standard UART driver
#option        CONS_BAUD=B9600
option        CONS_BAUD=B115200
select        ext2
select        fatfs
select        ramfiles
#select        mod_x86emu        # X86 emulation for VGA
option        MY40IO
option        NOPCINAMES        # Save some space for x86emu
#option        FASTBOOT
#select        vt82c686        #via686a/b code
#option        VGA_BASE=0xb0000000

#
# Functional options.
#
option        NOSNOOP            # Caches are no-snooping

#
# HAVE options. What tgt level provide
#
option        HAVE_TOD        # Time-Of-Day clock
option        HAVE_NVENV        #  Platform has non-volatile env mem
#option        HAVE_LOGO        # Output splash logo
#option        USE_SUPERIO_UART
#option        USE_LEGACY_RTC
#option        GODSONEV2A
#option        LINUX_PC
#option        LONGMENG
#option        RADEON7000
#option     DEBUG_EMU_VGA
#option        AUTOLOAD
#option        CONFIG_PCI0_LARGE_MEM    
#option        CONFIG_PCI0_HUGE_MEM    
#option        CONFIG_PCI0_GAINT_MEM    
option        CONFIG_CACHE_64K_4WAY
option        NVRAM_IN_FLASH    

#
#  Now the Machine specification
#
mainbus0        at root
localbus0    at mainbus0
#loopdev0    at mainbus0
#fd0        at mainbus0
pcibr0        at mainbus0
#pcibr1        at mainbus0
pci*        at pcibr?
ppb*        at pci? dev ? function ?    # PCI-PCI bridges
pci*        at ppb? bus ?

#lahci0        at localbus0 base 0xbfe60000    # AHCI
#ahci_sd*      at lahci0
#ahci_cdrom*      at lahci0

ahci*        at pci? dev ? function ?
ahci_sd*      at ahci?
ahci_cdrom*      at ahci?
#### USB
#uhci*        at pci? dev ? function ?
ohci*       at pci? dev ? function ?    # OHCI
usb*          at ohci?

##lxhci0        at localbus0 base 0xbfe38000    # xHCI
pcixhci*        at pci? dev ? function ?
xhci*        at pcixhci?
usb*        at xhci?
#usbnet*          at xhci?
select          mod_usb_xhci

#pcinvme*    at pci? dev ? function ?
#nvme*        at pcinvme?

#### SCSI support
#siop*        at pci? dev ? function ?    # Symbios/NCR 53c...
#scsibus*    at siop?
#sd*        at scsibus? target ? lun ? 
#cd*        at scsibus? target ? lun ? 
#option        CONFIG_LSI_9260        # for LSI_9260-8i(2108) RAID card support

#### Networking Devices
#gt0        at localbus? base 4
#gt1        at localbus? base 5
#gt2        at localbus? base 6
# fxp normally only used for debugging (enable/disable both)
#fxp0            at pci? dev ? function ?        # Intel 82559 Device
#inphy*          at mii? phy ?                   # Intel 82555 PHYs
#brgphy*        at mii? phy ?                   # Broadcom PHYs
#rtl*        at pci? dev ? function ?
#rtk*        at pci? dev ? function ?
em*            at pci? dev ? function ?
#igb*           at pci? dev ? function ?             #Intel 82576
#added by wxy
#bnx*            at pci? dev ? function ?                       # BCM5709S

#disable gmac
#pcisyn0        at pci? dev ? function ?
#pcisyn1        at pci? dev ? function ?
#select        gmac

select        mod_usb
select      mod_usb_storage
#select        mod_usb_uhci
select          mod_usb_ohci
select        mod_usb_kbd


#### IDE controllers
option          IDE_DMA
pciide*     at pci ? dev ? function ? flags 0x0000

#### IDE hard drives
wd*        at pciide? channel ? drive ? flags 0x0000
#wd0             at pciide? channel ? drive ? flags 0x0000
#cmdide*         at pci ? dev ? function ? flags 0x0000
#wd*             at cmdide? channel ? drive ? flags 0x0000

### wan+
### LSI MegaRAID SAS RAID controllers
#mfi*        at pci?
#scsibus*    at mfi?
#sd*        at scsibus? target ? lun ? 

#### Pseudo devices
pseudo-device    loop    1    # network loopback

ide_cd*     at pciide? channel ? drive ? flags 0x0001
select         iso9660
select        ramfiles
select         cmd_xyzmodem
option IDECD 
option HAVE_NB_SERIAL
#option USE_ENVMAC
#option LOOKLIKE_PC
#select cmd_lwdhcp
#select cmd_bootp
option FOR_GXEMUL
select fatfs
#option FLOATINGPT
#option PCI_IDSEL_VIA686B=17
#option PCI_IDSEL_SB700=14
option WDC_NORESET
select gzip
option INPUT_FROM_BOTH
option OUTPUT_TO_BOTH
#option VIA686B_POWERFIXUP
option DEVBD2F_VIA
#option USE_GPIO_SERIAL
option CONFIG_VIDEO_SW_CURSOR
select http
#select nfs
select tcp
select inet
select tftpd
#select e100
# SCSI RAID disk drive support
#select scsi_sd
#select raw_ether
 

稍微看一下的话,可能意识到这是个功能配置文件,对于这个系统,你需要选择哪些功能,或者使用了哪些自带的部分等。

2.顾名思义,pmoncfg要根据这个文件中的一些选项,产生一些宏定义(用于控制代码的条件编译)。

要细看的话,还得仔细分析pmoncfg的源代码才行。这里必然会生成一些h文件或者其他的配置文件。

单龙芯3A3000-7A1000PMON研究学习-(10)撸起袖子干-pmoncfg Bonito 干了什么?(这是make cfg的部分)_第1张图片

这里应该就是

a.创建软连接-----mksymlinks

static int
mksymlinks()
{
	int ret;
	char *p, buf[MAXPATHLEN];
	const char *q;

	sprintf(buf, "Targets/%s/include", machine);
	p = sourcepath(buf);
	(void)unlink("target");       //删除原来的链接
	ret = symlink(p, "target");   //1.创建新的连接
	if (ret)
		(void)fprintf(stderr, "config: symlink(target -> %s): %s\n",
		    p, strerror(errno));

	if (machinearch != NULL) {
		sprintf(buf, "sys/arch/%s/include", machinearch);
		p = sourcepath(buf);
		q = "machine";
	} else {
		p = strdup("machine");
		q = strdup("target");
	}
	(void)unlink(q);         //删除原链接 
	ret = symlink(p, q);     //2.创建新的链接
	if (ret)
		(void)fprintf(stderr, "config: symlink(%s -> %s): %s\n",
		    q, p, strerror(errno));
	free(p);

	return (ret);
}

这里我注释了两个地方创建新的连接。

注释1的链接文件

注释2的链接文件,注意这个目录的位置 

b.创建makefile----mkmakefile

int
mkmakefile()
{
	register FILE *ifp, *ofp;
	register int lineno;
	register int (*fn) (FILE *);
	register char *ifname;
	char line[BUFSIZ], buf[200];

	(void)sprintf(buf, "Targets/%s/conf/Makefile.%s", machine, machine);
	ifname = sourcepath(buf);
	if ((ifp = fopen(ifname, "r")) == NULL) {     //1.输入文件
		(void)fprintf(stderr, "config: cannot read %s: %s\n",
		    ifname, strerror(errno));
		free(ifname);
		return (1);
	}
	if ((ofp = fopen("Makefile", "w")) == NULL) {   //2.输出文件
		(void)fprintf(stderr, "config: cannot write Makefile: %s\n",
		    strerror(errno));
		free(ifname);
		return (1);
	}
	if (emitdefs(ofp) != 0)
		goto wrerror;
	lineno = 0;
	while (fgets(line, sizeof(line), ifp) != NULL) {   //3.从输入文件读1行,然后分析,然后继续循环读取
		lineno++;
		if (line[0] != '%') {           //4.一行的第一个字符不是%,则出错,
			if (fputs(line, ofp) < 0)   //5.写入文件失败,结束
				goto wrerror;
			continue;                   //6.继续读取下一行
		}
		if (strcmp(line, "%OBJS\n") == 0)     //7.这一行的内容是%OBJS
			fn = emitobjs;                     //8.函数指针赋值
		else if (strcmp(line, "%CFILES\n") == 0)
			fn = emitcfiles;
		else if (strcmp(line, "%SFILES\n") == 0)
			fn = emitsfiles;
		else if (strcmp(line, "%RULES\n") == 0)
			fn = emitrules;
		else if (strcmp(line, "%LOAD\n") == 0)
			fn = emitload;
		else {
			xerror(ifname, lineno,
			    "unknown %% construct ignored: %s", line);
			continue;                         //9.无法识别,下一行
		}
		if ((*fn)(ofp))                 //10.调用刚刚赋值的函数,参数传入输出文件描述符
			goto wrerror;
	}
	if (ferror(ifp)) {            //11.检查退出循环的原因,读文件出错了么?
		(void)fprintf(stderr,
		    "config: error reading %s (at line %d): %s\n",
		    ifname, lineno, strerror(errno));
		goto bad;
		/* (void)unlink("Makefile"); */
		free(ifname);
		return (1);
	}
	if (fclose(ofp)) {    //12.关闭输出文件
		ofp = NULL;
		goto wrerror;
	}
	(void)fclose(ifp);     //13.关闭输入文件
	free(ifname);
	return (0);           //14.正常返回0
wrerror:
	(void)fprintf(stderr, "config: error writing Makefile: %s\n",
	    strerror(errno));
bad:
	if (ofp != NULL)
		(void)fclose(ofp);
	/* (void)unlink("Makefile"); */
	free(ifname);
	return (1);
}

这里还有一些对应的函数要执行。

但是可以看出来,是生成了一个Makefile文件,看这个时间也是最新的,文件还不小。

内容非常多,我贴出一部分吧,前面这部分也是最重要的。

IDENT=-DVGAROM_IN_BIOS -DSYSTYPE="\"Bonito\"" -DTARGETNAME="\"Bonito\"" -Dloongson3A3 -DLSMC_2 -DDDR3_DIMM -DUSE_LS2H_I2C -DLOONGSON_GMAC -DBONITOEL -DDEVBD2F -DLS3_SERVER -DMIPS -DINET -DLS3_HT -DBOOTCORE_ID="0" -DRESERVED_COREMASK="0xfff0" -DSHUTDOWN_MASK="0" -DLOONGSON_3ASINGLE -DBONITO_33M -DBOOT_PARAM -DLS7A -DCONFIG_VIDEO_16BPP -DX1024x768 -DSERVER_3A -DVGA_NO_ROM -DVGA_BASE="0xbe000000" -DVRAM_SIZE="0x80" -DAUTOLOAD -DINTERFACE_3A780E -DDTB -DCONS_BAUD="B115200" -DMY40IO -DNOPCINAMES -DNOSNOOP -DHAVE_TOD -DHAVE_NVENV -DCONFIG_CACHE_64K_4WAY -DNVRAM_IN_FLASH -DIDE_DMA -DIDECD -DHAVE_NB_SERIAL -DFOR_GXEMUL -DWDC_NORESET -DINPUT_FROM_BOTH -DOUTPUT_TO_BOTH -DDEVBD2F_VIA -DCONFIG_VIDEO_SW_CURSOR
S!=	echo `/bin/pwd`/../../../..
ENDIAN=EL
ifndef S
S:=$(shell cd ../../../..; pwd)
endif
TARGET= ${S}/Targets/Bonito3a3000_7a
SUBTARGET?=Bonito
CPPFLAGS=-mips3

OBJS=	wdc.o mainbus.o pcibr.o if.o if_ethersubr.o if_loop.o if_media.o \
	radix.o raw_cb.o raw_usrreq.o route.o rtsock.o if_ether.o in.o \
	in_cksum.o in_pcb.o in_proto.o ip_icmp.o ip_id.o ip_input.o \
	ip_output.o raw_ip.o udp_usrreq.o tcp_debug.o tcp_input.o \
	tcp_output.o tcp_subr.o tcp_timer.o tcp_usrreq.o kern_clock.o \
	kern_misc.o kern_synch.o uipc_domain.o uipc_socket2.o \
	kern_descrip.o kern_proc.o kern_syscall.o sys_generic.o \
	subr_autoconf.o uipc_mbuf.o uipc_syscalls.o init_main.o \
	kern_malloc.o kern_sig.o kern_time.o sys_socket.o uipc_socket.o \
	bus_dma.o smbios.o uuid.o boot.o mycmd.o xyzModem.o crc16.o \
	sysinfo.o newmt.o setup.o display.o test.o cmdtable.o \
	debuggercmds.o devls.o cmd_go.o hist.o ifaddr.o oload.o load.o \
	tftpd.o cmd_grub.o memcmds.o memtst.o miscmds.o pcicmds.o \
	pflash.o cmd_env.o transp.o sym.o time.o shellcmds.o cmd_main.o \
	window.o bootparam.o about.o autoconf.o callvec.o cmdparser.o \
	debugger.o exception.o main.o more.o rsa.o sbrk.o env.o reset.o \
	ramfile.o termio.o socket.o gzip.o iso9660fs.o devfs.o diskfs.o \
	fatfs.o ext2fs.o dev_part.o loadfn.o exec.o exec_bin.o exec_elf.o \
	exec_elf64.o exec_srec.o netio.o bootp.o ifconfig.o ping.o \
	tftplib.o httplib.o debug.o decode.o fpu.o ops.o ops2.o \
	prim_ops.o sys.o generic.o helper_exec.o helper_mem.o xf86int10.o \
	xf86x86emu.o rs690_struct.o vesafb.o cfb_console.o kbd.o vgacon.o \
	generic_poll.o flash.o flashdev.o flash_amd.o flash_int.o \
	flash_sst.o flash_spi.o ns16550.o machdep.o mips_machdep.o \
	disassemble.o mips.o cache.o usb.o usb_storage.o part.o \
	usb-ohci.o usb_kbd.o cmd_usb.o xhci.o xhci-mem.o xhci-ring.o \
	xhci-dwc3.o exec_txt.o menulist2f.o boot_cfg.o bootkernel.o fdt.o \
	fdt_ro.o fdt_rw.o fdt_strerror.o fdt_wip.o password.o md5.o \
	install.o save_ddrparam.o showwindows.o w83527_fan.o \
	pci_machdep.o tgt_machdep.o ls7a_pci.o localbus.o eeprom.o \
	spi_w.o dc.o i2c-gpio.o ltc.o usb_spi.o ls7a_gmac_mac_init.o \
	load_dtb.o ls7a_dbg.o signal_test.o hda_test.o slt.o \
	synopGMAC_Dev.o synopGMAC_network_interface.o \
	synopGMAC_pci_bus_interface.o synopGMAC_plat.o dma_coherent.o \
	mii.o pciconf.o pci_map.o pci.o if_em.o pciide.o ppb.o pcidevs.o \
	ahci.o ahcisata.o ahci-sd.o ahci-cdrom.o wd.o ata_wdc.o ata.o \
	cd.o

CFILES=	$S/sys/dev/ic/wdc.c $S/pmon/dev/mainbus.c $S/pmon/dev/pcibr.c \
	$S/sys/net/if.c $S/sys/net/if_ethersubr.c $S/sys/net/if_loop.c \
	$S/sys/net/if_media.c $S/sys/net/radix.c $S/sys/net/raw_cb.c \
	$S/sys/net/raw_usrreq.c $S/sys/net/route.c $S/sys/net/rtsock.c \
	$S/sys/netinet/if_ether.c $S/sys/netinet/in.c \
	$S/sys/netinet/in_cksum.c $S/sys/netinet/in_pcb.c \
	$S/sys/netinet/in_proto.c $S/sys/netinet/ip_icmp.c \
	$S/sys/netinet/ip_id.c $S/sys/netinet/ip_input.c \
	$S/sys/netinet/ip_output.c $S/sys/netinet/raw_ip.c \
	$S/sys/netinet/udp_usrreq.c $S/sys/netinet/tcp_debug.c \
	$S/sys/netinet/tcp_input.c $S/sys/netinet/tcp_output.c \
	$S/sys/netinet/tcp_subr.c $S/sys/netinet/tcp_timer.c \
	$S/sys/netinet/tcp_usrreq.c $S/sys/kern/kern_clock.c \
	$S/sys/kern/kern_misc.c $S/sys/kern/kern_synch.c \
	$S/sys/kern/uipc_domain.c $S/sys/kern/uipc_socket2.c \
	$S/sys/kern/kern_descrip.c $S/sys/kern/kern_proc.c \
	$S/sys/kern/kern_syscall.c $S/sys/kern/sys_generic.c \
	$S/sys/kern/subr_autoconf.c $S/sys/kern/uipc_mbuf.c \
	$S/sys/kern/uipc_syscalls.c $S/sys/kern/init_main.c \
	$S/sys/kern/kern_malloc.c $S/sys/kern/kern_sig.c \
	$S/sys/kern/kern_time.c $S/sys/kern/sys_socket.c \
	$S/sys/kern/uipc_socket.c $S/sys/dev/bus_dma.c \
	$S/pmon/common/smbios/smbios.c $S/pmon/common/smbios/uuid.c \
	$S/pmon/cmds/boot.c $S/pmon/cmds/mycmd.c $S/pmon/cmds/xyzModem.c \
	$S/pmon/cmds/crc16.c $S/pmon/cmds/sysinfo.c \
	$S/pmon/cmds/newmt/newmt.c $S/pmon/cmds/setup.c \
	$S/pmon/cmds/display.c $S/pmon/cmds/test/test.c \
	$S/pmon/cmds/cmdtable.c $S/pmon/cmds/debuggercmds.c \
	$S/pmon/cmds/devls.c $S/pmon/cmds/cmd_go.c $S/pmon/cmds/hist.c \
	$S/pmon/cmds/ifaddr.c $S/pmon/cmds/oload.c $S/pmon/cmds/load.c \
	$S/pmon/cmds/tftpd.c $S/pmon/cmds/cmd_grub.c \
	$S/pmon/cmds/memcmds.c $S/pmon/cmds/memtst.c \
	$S/pmon/cmds/miscmds.c $S/pmon/cmds/pcicmds.c \
	$S/pmon/cmds/pflash.c $S/pmon/cmds/cmd_env.c \
	$S/pmon/cmds/transp.c $S/pmon/cmds/sym.c $S/pmon/cmds/time.c \
	$S/pmon/cmds/shellcmds.c $S/pmon/cmds/cmd_main/cmd_main.c \
	$S/pmon/cmds/cmd_main/window.c $S/pmon/cmds/bootparam.c \
	$S/pmon/common/about.c $S/pmon/common/autoconf.c \
	$S/pmon/common/callvec.c $S/pmon/common/cmdparser.c \
	$S/pmon/common/debugger.c $S/pmon/common/exception.c \
	$S/pmon/common/main.c $S/pmon/common/more.c $S/pmon/common/rsa.c \
	$S/pmon/common/sbrk.c $S/pmon/common/env.c $S/pmon/fs/ramfile.c \
	$S/pmon/fs/termio.c $S/pmon/fs/socket.c $S/pmon/fs/gzip.c \
	$S/pmon/fs/iso9660fs.c $S/pmon/fs/devfs.c $S/pmon/fs/diskfs.c \
	$S/pmon/fs/fatfs.c $S/pmon/fs/ext2fs.c $S/pmon/fs/dev_part.c \
	$S/pmon/loaders/loadfn.c $S/pmon/loaders/exec.c \
	$S/pmon/loaders/exec_bin.c $S/pmon/loaders/exec_elf.c \
	$S/pmon/loaders/exec_elf64.c $S/pmon/loaders/exec_srec.c \
	$S/pmon/netio/netio.c $S/pmon/netio/bootp.c \
	$S/pmon/netio/ifconfig.c $S/pmon/netio/ping.c \
	$S/pmon/netio/tftplib.c $S/pmon/netio/httplib.c \
	$S/x86emu/int10/x86emu/src/x86emu/debug.c \
	$S/x86emu/int10/x86emu/src/x86emu/decode.c \
	$S/x86emu/int10/x86emu/src/x86emu/fpu.c \
	$S/x86emu/int10/x86emu/src/x86emu/ops.c \
	$S/x86emu/int10/x86emu/src/x86emu/ops2.c \
	$S/x86emu/int10/x86emu/src/x86emu/prim_ops.c \
	$S/x86emu/int10/x86emu/src/x86emu/sys.c $S/x86emu/int10/generic.c \
	$S/x86emu/int10/helper_exec.c $S/x86emu/int10/helper_mem.c \
	$S/x86emu/int10/xf86int10.c $S/x86emu/int10/xf86x86emu.c \
	$S/x86emu/int10/rs690_struct.c $S/x86emu/int10/vesafb.c \
	$S/fb/cfb_console.c $S/pmon/dev/kbd.c $S/pmon/dev/vgacon.c \
	$S/pmon/dev/generic_poll.c $S/pmon/dev/flash.c \
	$S/pmon/dev/flashdev.c $S/pmon/dev/flash_amd.c \
	$S/pmon/dev/flash_int.c $S/pmon/dev/flash_sst.c \
	$S/pmon/dev/flash_spi.c $S/pmon/dev/ns16550.c \
	$S/pmon/arch/mips/machdep.c $S/pmon/arch/mips/mips_machdep.c \
	$S/pmon/arch/mips/disassemble.c $S/sys/dev/usb/usb.c \
	$S/sys/dev/usb/usb_storage.c $S/sys/dev/usb/part.c \
	$S/sys/dev/usb/usb-ohci.c $S/sys/dev/usb/usb_kbd.c \
	$S/sys/dev/usb/cmd_usb.c $S/sys/dev/usb/xhci.c \
	$S/sys/dev/usb/xhci-mem.c $S/sys/dev/usb/xhci-ring.c \
	$S/sys/dev/usb/xhci-dwc3.c $S/pmon/loaders/exec_txt.c \
	$S/pmon/cmds/menulist2f.c $S/pmon/cmds/boot_cfg.c \
	$S/pmon/common/bootkernel.c $S/lib/libfdt/fdt.c \
	$S/lib/libfdt/fdt_ro.c $S/lib/libfdt/fdt_rw.c \
	$S/lib/libfdt/fdt_strerror.c $S/lib/libfdt/fdt_wip.c \
	$S/pmon/cmds/password.c $S/pmon/dev/md5.c $S/pmon/cmds/install.c \
	$S/pmon/cmds/save_ddrparam.c $S/pmon/cmds/showwindows.c \
	$S/pmon/cmds/w83527_fan.c \
	$S/Targets/Bonito3a3000_7a/pci/pci_machdep.c \
	$S/Targets/Bonito3a3000_7a/Bonito/tgt_machdep.c \
	$S/Targets/Bonito3a3000_7a/pci/ls7a_pci.c \
	$S/Targets/Bonito3a3000_7a/dev/localbus.c \
	$S/Targets/Bonito3a3000_7a/dev/eeprom.c \
	$S/Targets/Bonito3a3000_7a/dev/spi_w.c \
	$S/Targets/Bonito3a3000_7a/dev/dc.c \
	$S/Targets/Bonito3a3000_7a/dev/i2c-gpio.c \
	$S/Targets/Bonito3a3000_7a/dev/ltc.c \
	$S/Targets/Bonito3a3000_7a/dev/usb_spi.c \
	$S/Targets/Bonito3a3000_7a/dev/ls7a_gmac_mac_init.c \
	$S/Targets/Bonito3a3000_7a/dev/load_dtb.c \
	$S/Targets/Bonito3a3000_7a/dev/ls7a_dbg.c \
	$S/Targets/Bonito3a3000_7a/dev/signal_test.c \
	$S/Targets/Bonito3a3000_7a/dev/hda_test.c \
	$S/Targets/Bonito3a3000_7a/dev/slt.c \
	$S/sys/dev/gmac/synopGMAC_Dev.c \
	$S/sys/dev/gmac/synopGMAC_network_interface.c \
	$S/sys/dev/gmac/synopGMAC_pci_bus_interface.c \
	$S/sys/dev/gmac/synopGMAC_plat.c \
	$S/pmon/arch/mips/ls3a/dma_coherent.c $S/sys/dev/mii/mii.c \
	$S/sys/dev/pci/pciconf.c $S/sys/dev/pci/pci_map.c \
	$S/sys/dev/pci/pci.c $S/sys/dev/pci/e1000e/if_em.c \
	$S/sys/dev/pci/pciide.c $S/sys/dev/pci/ppb.c \
	$S/sys/dev/pci/pcidevs.c $S/sys/dev/pci/ahci.c \
	$S/sys/dev/pci/ahcisata.c $S/sys/dev/pci/ahci-sd.c \
	$S/sys/dev/pci/ahci-cdrom.c $S/sys/dev/ata/wd.c \
	$S/sys/dev/ata/ata_wdc.c $S/sys/dev/ata/ata.c $S/sys/dev/ata/cd.c

SFILES=

all: pmon

pmon: ${SYSTEM_DEP} newvers
	${SYSTEM_LD_HEAD}
	${SYSTEM_LD}
	${SYSTEM_LD_TAIL}


export CFILES OBJS SFILES
include ${S}/Makefile.inc

wdc.o: $S/sys/dev/ic/wdc.c
	${NORMAL_C}

mainbus.o: $S/pmon/dev/mainbus.c
	${NORMAL_C}

pcibr.o: $S/pmon/dev/pcibr.c
	${NORMAL_C}

if.o: $S/sys/net/if.c
	${NORMAL_C}

if_ethersubr.o: $S/sys/net/if_ethersubr.c
	${NORMAL_C}

if_loop.o: $S/sys/net/if_loop.c
	${NORMAL_C}

if_media.o: $S/sys/net/if_media.c
	${NORMAL_C}

radix.o: $S/sys/net/radix.c
	${NORMAL_C}

这里涉及了一些目标。包括编译时的一些宏定义(第一行),应该说是非常重要的一个文件。

c.创建头文件----mkheaders

这一块似乎看不出啥。贴个代码吧,其实没啥意义

int
mkheaders()
{
	register struct files *fi;
	register struct nvlist *nv;

	for (fi = allfiles; fi != NULL; fi = fi->fi_next) {
		if (fi->fi_flags & FI_HIDDEN)
			continue;
		if (fi->fi_flags & (FI_NEEDSCOUNT | FI_NEEDSFLAG) &&
		    emitcnt(fi->fi_optf))
			return (1);
	}

	for (nv = defoptions; nv != NULL; nv = nv->nv_next)
		if (emitopt(nv))
			return (1);

	return (0);
}

d.创建ioconf文件。 -----mkioconf

int
mkioconf()
{
	register FILE *fp;
	int v;

	qsort(packed, npacked, sizeof *packed, cforder);
	if ((fp = fopen("ioconf.c", "w")) == NULL) {
		(void)fprintf(stderr, "config: cannot write ioconf.c: %s\n",
		    strerror(errno));
		return (1);
	}
	v = emithdr(fp);
	if (v != 0 || emitexterns(fp) || emitloc(fp) ||
	    emitlocnames(fp) || emitpv(fp) || emitcfdata(fp) ||
	    emitroots(fp) || emitpseudo(fp)) {
		if (v >= 0)
			(void)fprintf(stderr,
			    "config: error writing ioconf.c: %s\n",
			    strerror(errno));
		(void)fclose(fp);
		/* (void)unlink("ioconf.c"); */
		return (1);
	}
        if (fputs("#endif /* NMAINBUS */\n", fp) < 0)
        	return (1);
	(void)fclose(fp);
	return (0);
}

具体内容参考ioconf.c,这部分内容应该是比较重要的,c代码阶段就要用到了。留着下次分析吧。

/*
 * MACHINE GENERATED: DO NOT EDIT
 *
 * ioconf.c, from "Bonito"
 */

#include "mainbus.h"
#if NMAINBUS > 0
#include 
#include 

extern struct cfdriver mainbus_cd;
extern struct cfdriver pcibr_cd;
extern struct cfdriver usb_cd;
extern struct cfdriver xhci_cd;
extern struct cfdriver localbus_cd;
extern struct cfdriver pci_cd;
extern struct cfdriver em_cd;
extern struct cfdriver pciide_cd;
extern struct cfdriver ppb_cd;
extern struct cfdriver ohci_cd;
extern struct cfdriver pcixhci_cd;
extern struct cfdriver ahci_cd;
extern struct cfdriver ahci_sd_cd;
extern struct cfdriver ahci_cdrom_cd;
extern struct cfdriver wd_cd;
extern struct cfdriver ide_cd_cd;

extern struct cfattach mainbus_ca;
extern struct cfattach pcibr_ca;
extern struct cfattach usb_ca;
extern struct cfattach xhci_ca;
extern struct cfattach localbus_ca;
extern struct cfattach pci_ca;
extern struct cfattach em_ca;
extern struct cfattach pciide_ca;
extern struct cfattach ppb_ca;
extern struct cfattach ohci_ca;
extern struct cfattach pcixhci_ca;
extern struct cfattach ahci_ca;
extern struct cfattach ahci_sd_ca;
extern struct cfattach ahci_cdrom_ca;
extern struct cfattach wd_ca;
extern struct cfattach ide_cd_ca;


/* locators */
static int loc[2] = {
	-1, -1,
};

#ifndef MAXEXTRALOC
#define MAXEXTRALOC 32
#endif
int extraloc[MAXEXTRALOC];
int nextraloc = MAXEXTRALOC;
int uextraloc = 0;

char *locnames[] = {
	"bus",
	"dev",
	"function",
	"channel",
	"drive",
};

/* each entry is an index into locnames[]; -1 terminates */
short locnamp[] = {
	-1, 0, -1, 0, -1, 1, 2, -1,
	3, 4, -1,
};

/* size of parent vectors */
int pv_size = 16;

/* parent vectors */
short pv[16] = {
	1, 8, -1, 9, 3, -1, 5, -1, 7, -1, 0, -1, 10, -1, 11, -1,
};

#define NORM FSTATE_NOTFOUND
#define STAR FSTATE_STAR
#define DNRM FSTATE_DNOTFOUND
#define DSTR FSTATE_DSTAR

struct cfdata cfdata[] = {
    /* attachment       driver        unit  state loc     flags parents nm ivstubs starunit1 */
/*  0: mainbus0 at root */
    {&mainbus_ca,	&mainbus_cd,	 0, NORM,     loc,    0, pv+ 2, 0, 0,    0},
/*  1: pcibr0 at mainbus0 */
    {&pcibr_ca,		&pcibr_cd,	 0, NORM,     loc,    0, pv+10, 0, 0,    0},
/*  2: usb* at ohci*|xhci* */
    {&usb_ca,		&usb_cd,	 0, STAR,     loc,    0, pv+ 3, 0, 0,    0},
/*  3: xhci* at pcixhci* */
    {&xhci_ca,		&xhci_cd,	 0, STAR,     loc,    0, pv+12, 0, 0,    0},
/*  4: localbus0 at mainbus0 */
    {&localbus_ca,	&localbus_cd,	 0, NORM,     loc,    0, pv+10, 0, 0,    0},
/*  5: pci* at pcibr0|ppb* bus -1 */
    {&pci_ca,		&pci_cd,	 0, STAR, loc+  1,    0, pv+ 0, 1, 0,    0},
/*  6: em* at pci* dev -1 function -1 */
    {&em_ca,		&em_cd,		 0, STAR, loc+  0,    0, pv+ 6, 5, 0,    0},
/*  7: pciide* at pci* dev -1 function -1 */
    {&pciide_ca,	&pciide_cd,	 0, STAR, loc+  0,    0, pv+ 6, 5, 0,    0},
/*  8: ppb* at pci* dev -1 function -1 */
    {&ppb_ca,		&ppb_cd,	 0, STAR, loc+  0,    0, pv+ 6, 5, 0,    0},
/*  9: ohci* at pci* dev -1 function -1 */
    {&ohci_ca,		&ohci_cd,	 0, STAR, loc+  0,    0, pv+ 6, 5, 0,    0},
/* 10: pcixhci* at pci* dev -1 function -1 */
    {&pcixhci_ca,	&pcixhci_cd,	 0, STAR, loc+  0,    0, pv+ 6, 5, 0,    0},
/* 11: ahci* at pci* dev -1 function -1 */
    {&ahci_ca,		&ahci_cd,	 0, STAR, loc+  0,    0, pv+ 6, 5, 0,    0},
/* 12: ahci_sd* at ahci* */
    {&ahci_sd_ca,	&ahci_sd_cd,	 0, STAR,     loc,    0, pv+14, 7, 0,    0},
/* 13: ahci_cdrom* at ahci* */
    {&ahci_cdrom_ca,	&ahci_cdrom_cd,	 0, STAR,     loc,    0, pv+14, 7, 0,    0},
/* 14: wd* at pciide* channel -1 drive -1 */
    {&wd_ca,		&wd_cd,		 0, STAR, loc+  0,    0, pv+ 8, 8, 0,    0},
/* 15: ide_cd* at pciide* channel -1 drive -1 */
    {&ide_cd_ca,	&ide_cd_cd,	 0, STAR, loc+  0,  0x1, pv+ 8, 8, 0,    0},
    {0},
    {0},
    {0},
    {0},
    {0},
    {0},
    {0},
    {0},
    {(struct cfattach *)-1}
};

short cfroots[] = {
	 0 /* mainbus0 */,
	-1
};

int cfroots_size = 2;

/* pseudo-devices */
extern void loopattach (int);

char *pdevnames[] = {
	"loop",
};

int pdevnames_size = 1;

struct pdevinit pdevinit[] = {
	{ loopattach, 1 },
	{ 0, 0 }
};
#endif /* NMAINBUS */

3.前面的分析部分,太复杂了点,我一时半会可能就没去看了。以后有时间再研究一下,请大伙原谅

4.稍微总结一下:

4.1 pmon的功能配置就是在这个文件Targets/Bonito3a3000_7a/conf/Bonito.3a3000_7a中。后面分析代码的时候,有很多的宏定义就出自这里。所以需要特别注意

4.2 留意一下前面产生的链接文件,及makefile等。分析代码的时候跟这个有关

你可能感兴趣的:(龙芯3A3000-PMON,PMON)