User:Jesionaj/Listings

From eLinux.org
Jump to: navigation, search

Listing 2-6

Texas Instruments X-Loader 1.4.2 (Feb 19 2009 - 12:01:24)
Reading boot sector
Loading u-boot.bin from mmc


U-Boot 2009.11-rc1 (Jan 08 2010 - 21:19:52)

OMAP3530-GP ES3.0, CPU-OPP2 L3-165MHz
OMAP3 Beagle board + LPDDR/NAND
I2C:   ready
DRAM:  256 MB
NAND:  256 MiB
In:    serial
Out:   serial
Err:   serial
Board revision C1/C2/C3
Die ID #5ac400030000000004013f8901001001
Hit any key to stop autoboot:  0
OMAP3 beagleboard.org #

Listing 4-3

adam@melchoir linux-2.6.33.y]$ ls -l arch/arm/mach-omap2/
total 1.7M
-rw-r--r-- 1 adam users 5.1K Mar 12 00:59 board-2430sdp.c
-rw-r--r-- 1 adam users  17K Mar 12 00:59 board-3430sdp.c
-rwxr-xr-x 1 adam users 2.6K Mar 12 00:59 board-3630sdp.c
-rw-r--r-- 1 adam users 2.5K Mar 12 00:59 board-4430sdp.c
-rw-r--r-- 1 adam users 2.4K Mar 12 00:59 board-am3517evm.c
-rw-r--r-- 1 adam users 8.5K Mar 12 00:59 board-apollon.c
-rw-r--r-- 1 adam users  17K Mar 12 00:59 board-cm-t35.c
-rw-r--r-- 1 adam users 1.8K Mar 12 00:59 board-generic.c
-rw-r--r-- 1 adam users 9.2K Mar 12 00:59 board-h4.c
-rw-r--r-- 1 adam users 6.5K Mar 12 00:59 board-igep0020.c
-rw-r--r-- 1 adam users 9.1K Mar 12 00:59 board-ldp.c
-rw-r--r-- 1 adam users 3.4K Mar 12 00:59 board-n8x0.c
-rw-r--r-- 1 adam users  12K Mar 12 00:59 board-omap3beagle.c
-rw-r--r-- 1 adam users  12K Mar 12 00:59 board-omap3evm.c
-rw-r--r-- 1 adam users  11K Mar 12 00:59 board-omap3pandora.c
-rw-r--r-- 1 adam users  14K Mar 12 00:59 board-omap3touchbook.c
-rw-r--r-- 1 adam users  13K Mar 12 00:59 board-overo.c
-rw-r--r-- 1 adam users 2.6K Mar 12 00:59 board-rx51.c
-rw-r--r-- 1 adam users  19K Mar 12 00:59 board-rx51-peripherals.c
-rw-r--r-- 1 adam users 4.8K Mar 12 00:59 board-rx51-sdram.c
-rw-r--r-- 1 adam users 2.3K Mar 12 00:59 board-zoom2.c
-rw-r--r-- 1 adam users 1.6K Mar 12 00:59 board-zoom3.c
-rw-r--r-- 1 adam users 3.8K Mar 12 00:59 board-zoom-debugboard.c
-rwxr-xr-x 1 adam users 6.5K Mar 12 00:59 board-zoom-peripherals.c
-rw-r--r-- 1 adam users  16K Mar 12 00:59 clock2xxx.c
-rw-r--r-- 1 adam users  70K Mar 12 00:59 clock2xxx_data.c
-rw-r--r-- 1 adam users 1.5K Mar 12 00:59 clock2xxx.h
-rw-r--r-- 1 adam users 9.6K Mar 12 00:59 clock34xx.c
-rw-r--r-- 1 adam users  97K Mar 12 00:59 clock34xx_data.c
-rw-r--r-- 1 adam users  741 Mar 12 00:59 clock34xx.h
-rw-r--r-- 1 adam users  849 Mar 12 00:59 clock44xx.c
-rw-r--r-- 1 adam users  82K Mar 12 00:59 clock44xx_data.c
-rw-r--r-- 1 adam users  321 Mar 12 00:59 clock44xx.h
-rw-r--r-- 1 adam users  30K Mar 12 00:59 clock.c
-rw-r--r-- 1 adam users 1.2K Mar 12 00:59 clock_common_data.c
-rw-r--r-- 1 adam users  17K Mar 12 00:59 clockdomain.c
-rw-r--r-- 1 adam users 8.9K Mar 12 00:59 clockdomains.h
-rw-r--r-- 1 adam users 3.9K Mar 12 00:59 clock.h
-rw-r--r-- 1 adam users  29K Mar 12 00:59 cm44xx.h
-rw-r--r-- 1 adam users 1.4K Mar 12 00:59 cm4xxx.c
-rw-r--r-- 1 adam users 1.7K Mar 12 00:59 cm.c
-rw-r--r-- 1 adam users 4.3K Mar 12 00:59 cm.h
-rw-r--r-- 1 adam users  14K Mar 12 00:59 cm-regbits-24xx.h
-rw-r--r-- 1 adam users  26K Mar 12 00:59 cm-regbits-34xx.h
-rw-r--r-- 1 adam users  61K Mar 12 00:59 cm-regbits-44xx.h
-rw-r--r-- 1 adam users  15K Mar 12 00:59 control.c
-rw-r--r-- 1 adam users 9.6K Mar 12 00:59 cpuidle34xx.c
-rw-r--r-- 1 adam users  18K Mar 12 00:59 devices.c
-rw-r--r-- 1 adam users  14K Mar 12 00:59 dpll.c
-rw-r--r-- 1 adam users 1.5K Mar 12 00:59 emu.c
-rw-r--r-- 1 adam users  15K Mar 12 00:59 gpmc.c
-rw-r--r-- 1 adam users 9.2K Mar 12 00:59 gpmc-onenand.c
-rw-r--r-- 1 adam users 5.0K Mar 12 00:59 gpmc-smc91x.c
-rw-r--r-- 1 adam users 1.7K Mar 12 00:59 i2c.c
-rw-r--r-- 1 adam users  11K Mar 12 00:59 id.c
drwxr-xr-x 3 adam users 4.0K Mar 12 00:59 include/
-rw-r--r-- 1 adam users 7.7K Mar 12 00:59 io.c
-rw-r--r-- 1 adam users 7.8K Mar 12 00:59 iommu2.c
-rw-r--r-- 1 adam users 7.4K Mar 12 00:59 irq.c
-rw-r--r-- 1 adam users 3.9K Mar 12 00:59 Kconfig

With User:Jiangq

Chapter 4

Number Page Caption Listing
4-3 4-15 Kernel Subdirectory
  qiang@qiang-laptop:~/Desktop/linux-2.6$ cat 4_3
qiang@qiang-laptop:~/Desktop/linux-2.6$ ls -ls arch/arm/plat-omap/ | grep -v \\.o
total 432
12 -rw-r--r-- 1 qiang qiang 11124 2010-03-23 20:06 clock.c
12 -rw-r--r-- 1 qiang qiang  8521 2010-03-23 20:06 common.c
 4 -rw-r--r-- 1 qiang qiang  4033 2010-03-23 20:06 cpu-omap.c
 4 -rw-r--r-- 1 qiang qiang  2192 2010-03-23 20:06 debug-devices.c
 8 -rw-r--r-- 1 qiang qiang  7170 2010-03-23 20:06 debug-leds.c
12 -rw-r--r-- 1 qiang qiang 10890 2010-03-23 20:06 devices.c
56 -rw-r--r-- 1 qiang qiang 52586 2010-03-23 20:06 dma.c
24 -rw-r--r-- 1 qiang qiang 22660 2010-03-23 20:06 dmtimer.c
12 -rw-r--r-- 1 qiang qiang 10055 2010-03-23 20:06 fb.c
64 -rw-r--r-- 1 qiang qiang 61308 2010-03-23 20:06 gpio.c
 8 -rw-r--r-- 1 qiang qiang  5058 2010-03-23 20:06 i2c.c
 4 drwxr-xr-x 3 qiang qiang  4096 2010-03-23 20:06 include
 8 -rw-r--r-- 1 qiang qiang  6265 2010-03-23 20:06 io.c
24 -rw-r--r-- 1 qiang qiang 20765 2010-03-23 20:06 iommu.c
12 -rw-r--r-- 1 qiang qiang  9117 2010-03-23 20:06 iommu-debug.c
 4 -rw-r--r-- 1 qiang qiang  2745 2010-03-23 20:06 iopgtable.h
20 -rw-r--r-- 1 qiang qiang 19320 2010-03-23 20:06 iovmm.c
 8 -rw-r--r-- 1 qiang qiang  4819 2010-03-23 20:06 Kconfig
12 -rw-r--r-- 1 qiang qiang  8522 2010-03-23 20:06 mailbox.c
 4 -rw-r--r-- 1 qiang qiang   882 2010-03-23 20:06 Makefile
44 -rw-r--r-- 1 qiang qiang 43730 2010-03-23 20:06 mcbsp.c
 4 -rw-r--r-- 1 qiang qiang  2263 2010-03-23 20:06 mux.c
 4 -rw-r--r-- 1 qiang qiang  2739 2010-03-23 20:06 ocpi.c
24 -rw-r--r-- 1 qiang qiang 21397 2010-03-23 20:06 omap_device.c
 8 -rw-r--r-- 1 qiang qiang  7069 2010-03-23 20:06 omap-pm-noop.c
16 -rw-r--r-- 1 qiang qiang 12878 2010-03-23 20:06 sram.c
20 -rw-r--r-- 1 qiang qiang 18770 2010-03-23 20:06 usb.c

4-4 4-17 Snippet from Linux 2.6.config
qiang@qiang-laptop:~/Desktop/linux-2.6$ cat 4_4
#
# CONFIG_64BIT is not set
CONFIG_X86_32=y
# CONFIG_X86_64 is not set
CONFIG_X86=y
CONFIG_OUTPUT_FORMAT="elf32-i386"
CONFIG_ARCH_DEFCONFIG="arch/x86/configs/i386_defconfig"
CONFIG_GENERIC_TIME=y
CONFIG_GENERIC_CMOS_UPDATE=y
CONFIG_CLOCKSOURCE_WATCHDOG=y
CONFIG_GENERIC_CLOCKEVENTS=y
CONFIG_GENERIC_CLOCKEVENTS_BROADCAST=y
CONFIG_LOCKDEP_SUPPORT=y
CONFIG_STACKTRACE_SUPPORT=y
CONFIG_HAVE_LATENCYTOP_SUPPORT=y
CONFIG_MMU=y

4-6 4-22 Makefile Targets
qiang@qiang-laptop:~/Desktop/linux-2.6$ cat 4_6
qiang@qiang-laptop:~/Desktop/linux-2.6$ make help
Cleaning targets:
  clean		  - Remove most generated files but keep the config and
                    enough build support to build external modules
  mrproper	  - Remove all generated files + config + various backup files
  distclean	  - mrproper + remove editor backup and patch files

Configuration targets:
  config	  - Update current config utilising a line-oriented program
  menuconfig	  - Update current config utilising a menu based program
  xconfig	  - Update current config utilising a QT based front-end
  gconfig	  - Update current config utilising a GTK based front-end
  oldconfig	  - Update current config utilising a provided .config as base
  localmodconfig  - Update current config disabling modules not loaded
  localyesconfig  - Update current config converting local mods to core
  silentoldconfig - Same as oldconfig, but quietly, additionally update deps
  randconfig	  - New config with random answer to all options
  defconfig	  - New config with default answer to all options
  allmodconfig	  - New config selecting modules when possible
  allyesconfig	  - New config where all options are accepted with yes
  allnoconfig	  - New config where all options are answered with no

Other generic targets:
  all		  - Build all targets marked with [*]
* vmlinux	  - Build the bare kernel
* modules	  - Build all modules
  modules_install - Install all modules to INSTALL_MOD_PATH (default: /)
  firmware_install- Install all firmware to INSTALL_FW_PATH
                    (default: $(INSTALL_MOD_PATH)/lib/firmware)
  dir/            - Build all files in dir and below
  dir/file.[ois]  - Build specified target only
  dir/file.ko     - Build module including final link
  modules_prepare - Set up for building external modules
  tags/TAGS	  - Generate tags file for editors
  cscope	  - Generate cscope index
  kernelrelease	  - Output the release version string
  kernelversion	  - Output the version stored in Makefile
  headers_install - Install sanitised kernel headers to INSTALL_HDR_PATH
                    (default: /home/qiang/Desktop/linux-2.6/usr)

Static analysers
  checkstack      - Generate a list of stack hogs
  namespacecheck  - Name space analysis on compiled kernel
  versioncheck    - Sanity check on version.h usage
  includecheck    - Check for duplicate included header files
  export_report   - List the usages of all exported symbols
  headers_check   - Sanity check on exported headers
  headerdep       - Detect inclusion cycles in headers

Kernel packaging:
  rpm-pkg         - Build both source and binary RPM kernel packages
  binrpm-pkg      - Build only the binary kernel package
  deb-pkg         - Build the kernel as an deb package
  tar-pkg         - Build the kernel as an uncompressed tarball
  targz-pkg       - Build the kernel as a gzip compressed tarball
  tarbz2-pkg      - Build the kernel as a bzip2 compressed tarball

Documentation targets:
 Linux kernel internal documentation in different formats:
  htmldocs        - HTML
  pdfdocs         - PDF
  psdocs          - Postscript
  xmldocs         - XML DocBook
  mandocs         - man pages
  installmandocs  - install man pages generated by mandocs
  cleandocs       - clean all generated DocBook files

Architecture specific targets (x86):
* bzImage      - Compressed kernel image (arch/x86/boot/bzImage)
  install      - Install kernel using
                  (your) ~/bin/installkernel or
                  (distribution) /sbin/installkernel or
                  install to $(INSTALL_PATH) and run lilo
  fdimage      - Create 1.4MB boot floppy image (arch/x86/boot/fdimage)
  fdimage144   - Create 1.4MB boot floppy image (arch/x86/boot/fdimage)
  fdimage288   - Create 2.8MB boot floppy image (arch/x86/boot/fdimage)
  isoimage     - Create a boot CD-ROM image (arch/x86/boot/image.iso)
                  bzdisk/fdimage*/isoimage also accept:
                  FDARGS="..."  arguments for the booted kernel
                  FDINITRD=file initrd for the booted kernel

  i386_defconfig           - Build for i386
  x86_64_defconfig         - Build for x86_64

  make V=0|1 [targets] 0 => quiet build (default), 1 => verbose build
  make V=2   [targets] 2 => give reason for rebuild of target
  make O=dir [targets] Locate all output files in "dir", including .config
  make C=1   [targets] Check all c source with $CHECK (sparse by default)
  make C=2   [targets] Force check of all c source with $CHECK

Execute "make" or "make all" to build all targets marked with [*] 
For further info see the ./README file

4-10 4-32 Customized .config File Snippet
qiang@qiang-laptop:~/Desktop/linux-2.6$ cat 4_10
# CONFIG_ARCH_PNX4008 is not set
# CONFIG_ARCH_PXA is not set
# CONFIG_ARCH_MSM is not set
# CONFIG_ARCH_SHMOBILE is not set
# CONFIG_ARCH_RPC is not set
# CONFIG_ARCH_SA1100 is not set
# CONFIG_ARCH_S3C2410 is not set
# CONFIG_ARCH_S3C64XX is not set
# CONFIG_ARCH_S5P6440 is not set
# CONFIG_ARCH_S5P6442 is not set
# CONFIG_ARCH_S5PC1XX is not set
# CONFIG_ARCH_S5PV210 is not set
# CONFIG_ARCH_SHARK is not set
# CONFIG_ARCH_LH7A40X is not set
# CONFIG_ARCH_U300 is not set
# CONFIG_ARCH_U8500 is not set
# CONFIG_ARCH_NOMADIK is not set
# CONFIG_ARCH_DAVINCI is not set
CONFIG_ARCH_OMAP=y

# 
# TI OMAP Implementations
# 
# CONFIG_ARCH_OMAP1 is not set
CONFIG_ARCH_OMAP2PLUS=y
# CONFIG_ARCH_OMAP2 is not set
# CONFIG_ARCH_OMAP3 is not set
# CONFIG_ARCH_OMAP4 is not set
4-11 4-33 Makefile from .../arch/arm/mach-ixp4xx Kernel Subdirectory
 qiang@qiang-laptop:~/Desktop/linux-2.6$ cat 4_11
qiang@qiang-laptop:~/Desktop/linux-2.6/arch/arm/plat-omap$ head -n 20 Makefile
#
# Makefile for the linux kernel.
#

# Common support
obj-y := common.o sram.o clock.o devices.o dma.o mux.o gpio.o \
	 usb.o fb.o io.o
obj-m :=
obj-n :=
obj-  :=

# OCPI interconnect support for 1710, 1610 and 5912
obj-$(CONFIG_ARCH_OMAP16XX) += ocpi.o

# omap_device support (OMAP2+ only at the moment)
obj-$(CONFIG_ARCH_OMAP2) += omap_device.o
obj-$(CONFIG_ARCH_OMAP3) += omap_device.o

obj-$(CONFIG_OMAP_MCBSP) += mcbsp.o
obj-$(CONFIG_OMAP_IOMMU) += iommu.o iovmm.o

Chapter 5

Number Page Caption Listing
5-2 5-5 Assembly File piggy.s
  qiang@qiang-laptop:~/Desktop/linux-2.6/arch/arm/boot/compressed$ cat piggy.gzip.S 
	.section .piggydata,#alloc
	.globl	input_data
input_data:
	.incbin	"arch/arm/boot/compressed/piggy.gzip"
	.globl	input_data_end
input_data_end:


5-4 5-18 Console Setup Code Snippet
qiang@qiang-laptop:~/Desktop/linux-2.6/arch/arm/boot/compressed$ cat piggy.gzip.S 
	.section .piggydata,#alloc
	.globl	input_data
input_data:
	.incbin	"arch/arm/boot/compressed/piggy.gzip"
	.globl	input_data_end
input_data_end:

qiang@qiang-laptop:~/Desktop/linux-2.6$ cat 5_4
/*
 * Set up a list of consoles.  Called from init/main.c
 */
static int __init console_setup(char *str)
{
        char buf[sizeof(console_cmdline[0].name) + 4]; /* 4 for index */
        char *s, *options, *brl_options = NULL;
        int idx;

#ifdef CONFIG_A11Y_BRAILLE_CONSOLE
        if (!memcmp(str, "brl,", 4)) {
                brl_options = "";
                str += 4;
        } else if (!memcmp(str, "brl=", 4)) {
                brl_options = str + 4;
                str = strchr(brl_options, ',');
                if (!str) {
                        printk(KERN_ERR "need port name after brl=\n");
                        return 1;
                }
                *(str++) = 0;


5-5 5-19 Family of _setup Macro Definitions from init.h
qiang@qiang-laptop:~/Desktop/linux-2.6$ cat 5_5
/*
 * Only for really core code.  See moduleparam.h for the normal way.
 * 
 * Force the alignment so the compiler doesn't space elements of the
 * obs_kernel_param "array" too far apart in .init.setup.
 */
#define __setup_param(str, unique_id, fn, early)                        \
        static const char __setup_str_##unique_id[] __initconst \
                __aligned(1) = str; \
        static struct obs_kernel_param __setup_##unique_id      \
                __used __section(.init.setup)                   \
                __attribute__((aligned((sizeof(long)))))        \
                = { __setup_str_##unique_id, fn, early }

#define __setup(str, fn)                                        \
        __setup_param(str, fn, fn, 0)


5-6 5-20 Kernel Command Line Processing
qiang@qiang-laptop:~/Desktop/linux-2.6$ cat 5_6
static int __init obsolete_checksetup(char *line)
{
        struct obs_kernel_param *p;
        int had_early_param = 0;

        p = __setup_start;
        do {
                int n = strlen(p->str);
                if (!strncmp(line, p->str, n)) {
                        if (p->early) {
                                /* Already done in parse_early_param?
                                 * (Needs exact match on param part).
                                 * Keep iterating, as we can have early
                                 * params and __setups of same names 8( */
                                if (line[n] == '\0' || line[n] == '=')
                                        had_early_param = 1;
                        } else if (!p->setup_func) {
                                printk(KERN_WARNING "Parameter %s is obsolete,"
                                       " ignored\n", p->str);
                                return 1;
                        } else if (p->setup_func(line + n))
                                return 1;
                }
                p++;
        } while (p < __setup_end);

        return had_early_param;
}

5-7 5-23 Example Initialization Routine
 qiang@qiang-laptop:~/Desktop/linux-2.6$ cat 5_7
static void (*init_machine)(void) __initdata;

static int __init customize_machine(void)
{
        /* customizes platform devices, or adds new ones */
        if (init_machine)
                init_machine();
        return 0;
}
5-8 5-23 initcall Family of Macros
 qiang@qiang-laptop:~/Desktop/linux-2.6$ cat 5_8
#define __define_initcall(level,fn,id) \
        static initcall_t __initcall_##fn##id __used \
        __attribute__((__section__(".initcall" level ".init"))) = fn

/*
 * Early initcalls run before initializing SMP.
 *
 * Only for built-in code, not modules.
 */
#define early_initcall(fn)              __define_initcall("early",fn,early)

/*
 * A "pure" initcall has no dependencies on anything else, and purely
 * initializes variables that couldn't be statically initialized.
 *
 * This only exists for built-in code, not for modules.
 */
#define pure_initcall(fn)               __define_initcall("0",fn,0)

#define core_initcall(fn)               __define_initcall("1",fn,1)
#define core_initcall_sync(fn)          __define_initcall("1s",fn,1s)
#define postcore_initcall(fn)           __define_initcall("2",fn,2)
#define postcore_initcall_sync(fn)      __define_initcall("2s",fn,2s)
#define arch_initcall(fn)               __define_initcall("3",fn,3)
#define arch_initcall_sync(fn)          __define_initcall("3s",fn,3s)
#define subsys_initcall(fn)             __define_initcall("4",fn,4)
#define subsys_initcall_sync(fn)        __define_initcall("4s",fn,4s)
5-9 5-26 Creation of Kernel init Thread
 qiang@qiang-laptop:~/Desktop/linux-2.6$ cat 5_9
static noinline void __init_refok rest_init(void)
        __releases(kernel_lock)
{
        int pid;

        rcu_scheduler_starting();
        kernel_thread(kernel_init, NULL, CLONE_FS | CLONE_SIGHAND);
        numa_default_policy();
        pid = kernel_thread(kthreadd, NULL, CLONE_FS | CLONE_FILES);
        rcu_read_lock();
        kthreadd_task = find_task_by_pid_ns(pid, &init_pid_ns);
        rcu_read_unlock();
        unlock_kernel();

        /*
         * The boot idle thread must execute schedule()
         * at least once to get things moving:
         */
        init_idle_bootup_task(current);
        preempt_enable_no_resched();
        schedule();
        preempt_disable();

        /* Call into cpu_idle with preempt disabled */
        cpu_idle();
}

5-10 5-27 Initialization via initcalls
 qiang@qiang-laptop:~/Desktop/linux-2.6$ cat 5_10
extern initcall_t __initcall_start[], __initcall_end[], __early_initcall_end[];

static void __init do_initcalls(void)
{
        initcall_t *fn;

        for (fn = __early_initcall_end; fn < __initcall_end; fn++)
                do_one_initcall(*fn);

        /* Make sure there is no pending stuff from the initcall sequence */
        flush_scheduled_work();
}
5-11 5-28 Final Kernel Boot Steps from main.c
qiang@qiang-laptop:~/Desktop/linux-2.6$ cat 5_11
 * makes it inline to init() and it becomes part of init.text section
 */
static noinline int init_post(void)
        __releases(kernel_lock)
{
        /* need to finish all async __init code before freeing the memory */
        async_synchronize_full();
        free_initmem();
        unlock_kernel();
        mark_rodata_ro();
        system_state = SYSTEM_RUNNING;
        numa_default_policy();


        current->signal->flags |= SIGNAL_UNKILLABLE;

        if (ramdisk_execute_command) {
                run_init_process(ramdisk_execute_command);
                printk(KERN_WARNING "Failed to execute %s\n",
                                ramdisk_execute_command);