Linux Audio

Check our new training course

Embedded Linux Audio

Check our new training course
with Creative Commons CC-BY-SA
lecture materials

 Bootlin logo

Elixir Cross Referencer

Loading...
 one
 two
 three
 four
 five
 six
 seven
 eight
 nine
 ten
 eleven
 twelve
 thirteen
 fourteen
 fifteen
 sixteen
 seventeen
 eighteen
 nineteen
 twenty
 twenty-one
 twenty-two
 twenty-three
 twenty-four
 twenty-five
 twenty-six
 twenty-seven
 twenty-eight
 twenty-nine
 thirty
 thirty-one
 thirty-two
 thirty-three
 thirty-four
 thirty-five
 thirty-six
 thirty-seven
 thirty-eight
 thirty-nine
 forty
 forty-one
 forty-two
 forty-three
 forty-four
 forty-five
 forty-six
 forty-seven
 forty-eight
 forty-nine
 fifty
 fifty-one
 fifty-two
 fifty-three
 fifty-four
 fifty-five
 fifty-six
 fifty-seven
 fifty-eight
 fifty-nine
 sixty
 sixty-one
 sixty-two
 sixty-three
 sixty-four
 sixty-five
 sixty-six
 sixty-seven
 sixty-eight
 sixty-nine
 seventy
 seventy-one
 seventy-two
 seventy-three
 seventy-four
 seventy-five
 seventy-six
 seventy-seven
 seventy-eight
 seventy-nine
 eighty
 eighty-one
 eighty-two
 eighty-three
 eighty-four
 eighty-five
 eighty-six
 eighty-seven
 eighty-eight
 eighty-nine
 ninety
 ninety-one
 ninety-two
 ninety-three
 ninety-four
 ninety-five
 ninety-six
 ninety-seven
 ninety-eight
 ninety-nine
 one hundred
 one hundred and one
 one hundred and two
 one hundred and three
 one hundred and four
 one hundred and five
 one hundred and six
 one hundred and seven
 one hundred and eight
 one hundred and nine
 one hundred and ten
 one hundred and eleven
 one hundred and twelve
 one hundred and thirteen
 one hundred and fourteen
 one hundred and fifteen
 one hundred and sixteen
 one hundred and seventeen
 one hundred and eighteen
 one hundred and nineteen
 one hundred and twenty
 one hundred and twenty-one
 one hundred and twenty-two
 one hundred and twenty-three
 one hundred and twenty-four
 one hundred and twenty-five
 one hundred and twenty-six
 one hundred and twenty-seven
 one hundred and twenty-eight
 one hundred and twenty-nine
 one hundred and thirty
 one hundred and thirty-one
 one hundred and thirty-two
 one hundred and thirty-three
 one hundred and thirty-four
 one hundred and thirty-five
 one hundred and thirty-six
 one hundred and thirty-seven
 one hundred and thirty-eight
 one hundred and thirty-nine
 one hundred and forty
 one hundred and forty-one
 one hundred and forty-two
 one hundred and forty-three
 one hundred and forty-four
 one hundred and forty-five
 one hundred and forty-six
 one hundred and forty-seven
 one hundred and forty-eight
 one hundred and forty-nine
 one hundred and fifty
 one hundred and fifty-one
 one hundred and fifty-two
 one hundred and fifty-three
 one hundred and fifty-four
 one hundred and fifty-five
 one hundred and fifty-six
 one hundred and fifty-seven
 one hundred and fifty-eight
 one hundred and fifty-nine
 one hundred and sixty
 one hundred and sixty-one
 one hundred and sixty-two
 one hundred and sixty-three
 one hundred and sixty-four
 one hundred and sixty-five
 one hundred and sixty-six
 one hundred and sixty-seven
 one hundred and sixty-eight
 one hundred and sixty-nine
 one hundred and seventy
 one hundred and seventy-one
 one hundred and seventy-two
 one hundred and seventy-three
 one hundred and seventy-four
 one hundred and seventy-five
 one hundred and seventy-six
 one hundred and seventy-seven
 one hundred and seventy-eight
 one hundred and seventy-nine
 one hundred and eighty
 one hundred and eighty-one
 one hundred and eighty-two
 one hundred and eighty-three
 one hundred and eighty-four
 one hundred and eighty-five
 one hundred and eighty-six
 one hundred and eighty-seven
 one hundred and eighty-eight
 one hundred and eighty-nine
 one hundred and ninety
 one hundred and ninety-one
 one hundred and ninety-two
 one hundred and ninety-three
 one hundred and ninety-four
 one hundred and ninety-five
 one hundred and ninety-six
 one hundred and ninety-seven
 one hundred and ninety-eight
 one hundred and ninety-nine
 two hundred
 two hundred and one
 two hundred and two
 two hundred and three
 two hundred and four
 two hundred and five
 two hundred and six
 two hundred and seven
 two hundred and eight
 two hundred and nine
 two hundred and ten
 two hundred and eleven
 two hundred and twelve
 two hundred and thirteen
 two hundred and fourteen
 two hundred and fifteen
 two hundred and sixteen
 two hundred and seventeen
 two hundred and eighteen
 two hundred and nineteen
 two hundred and twenty
 two hundred and twenty-one
 two hundred and twenty-two
 two hundred and twenty-three
 two hundred and twenty-four
 two hundred and twenty-five
 two hundred and twenty-six
 two hundred and twenty-seven
 two hundred and twenty-eight
 two hundred and twenty-nine
 two hundred and thirty
 two hundred and thirty-one
 two hundred and thirty-two
 two hundred and thirty-three
 two hundred and thirty-four
 two hundred and thirty-five
 two hundred and thirty-six
 two hundred and thirty-seven
 two hundred and thirty-eight
 two hundred and thirty-nine
 two hundred and forty
 two hundred and forty-one
 two hundred and forty-two
 two hundred and forty-three
 two hundred and forty-four
 two hundred and forty-five
 two hundred and forty-six
 two hundred and forty-seven
 two hundred and forty-eight
 two hundred and forty-nine
 two hundred and fifty
 two hundred and fifty-one
 two hundred and fifty-two
 two hundred and fifty-three
 two hundred and fifty-four
 two hundred and fifty-five
 two hundred and fifty-six
 two hundred and fifty-seven
 two hundred and fifty-eight
 two hundred and fifty-nine
 two hundred and sixty
 two hundred and sixty-one
 two hundred and sixty-two
 two hundred and sixty-three
 two hundred and sixty-four
 two hundred and sixty-five
 two hundred and sixty-six
 two hundred and sixty-seven
 two hundred and sixty-eight
 two hundred and sixty-nine
 two hundred and seventy
 two hundred and seventy-one
 two hundred and seventy-two
 two hundred and seventy-three
 two hundred and seventy-four
 two hundred and seventy-five
 two hundred and seventy-six
 two hundred and seventy-seven
 two hundred and seventy-eight
 two hundred and seventy-nine
 two hundred and eighty
 two hundred and eighty-one
 two hundred and eighty-two
 two hundred and eighty-three
 two hundred and eighty-four
 two hundred and eighty-five
 two hundred and eighty-six
 two hundred and eighty-seven
 two hundred and eighty-eight
 two hundred and eighty-nine
 two hundred and ninety
 two hundred and ninety-one
 two hundred and ninety-two
 two hundred and ninety-three
 two hundred and ninety-four
 two hundred and ninety-five
 two hundred and ninety-six
 two hundred and ninety-seven
 two hundred and ninety-eight
 two hundred and ninety-nine
 three hundred
 three hundred and one
 three hundred and two
 three hundred and three
 three hundred and four
 three hundred and five
 three hundred and six
 three hundred and seven
 three hundred and eight
 three hundred and nine
 three hundred and ten
 three hundred and eleven
 three hundred and twelve
 three hundred and thirteen
 three hundred and fourteen
 three hundred and fifteen
 three hundred and sixteen
 three hundred and seventeen
 three hundred and eighteen
 three hundred and nineteen
 three hundred and twenty
 three hundred and twenty-one
 three hundred and twenty-two
 three hundred and twenty-three
 three hundred and twenty-four
 three hundred and twenty-five
 three hundred and twenty-six
 three hundred and twenty-seven
 three hundred and twenty-eight
 three hundred and twenty-nine
 three hundred and thirty
 three hundred and thirty-one
 three hundred and thirty-two
 three hundred and thirty-three
 three hundred and thirty-four
 three hundred and thirty-five
 three hundred and thirty-six
 three hundred and thirty-seven
 three hundred and thirty-eight
 three hundred and thirty-nine
 three hundred and forty
 three hundred and forty-one
 three hundred and forty-two
 three hundred and forty-three
 three hundred and forty-four
 three hundred and forty-five
 three hundred and forty-six
 three hundred and forty-seven
 three hundred and forty-eight
 three hundred and forty-nine
 three hundred and fifty
 three hundred and fifty-one
 three hundred and fifty-two
 three hundred and fifty-three
 three hundred and fifty-four
 three hundred and fifty-five
 three hundred and fifty-six
 three hundred and fifty-seven
 three hundred and fifty-eight
 three hundred and fifty-nine
 three hundred and sixty
 three hundred and sixty-one
 three hundred and sixty-two
 three hundred and sixty-three
 three hundred and sixty-four
 three hundred and sixty-five
 three hundred and sixty-six
 three hundred and sixty-seven
 three hundred and sixty-eight
 three hundred and sixty-nine
 three hundred and seventy
 three hundred and seventy-one
 three hundred and seventy-two
 three hundred and seventy-three
 three hundred and seventy-four
 three hundred and seventy-five
 three hundred and seventy-six
 three hundred and seventy-seven
 three hundred and seventy-eight
 three hundred and seventy-nine
 three hundred and eighty
 three hundred and eighty-one
 three hundred and eighty-two
 three hundred and eighty-three
 three hundred and eighty-four
 three hundred and eighty-five
 three hundred and eighty-six
 three hundred and eighty-seven
 three hundred and eighty-eight
 three hundred and eighty-nine
 three hundred and ninety
 three hundred and ninety-one
 three hundred and ninety-two
 three hundred and ninety-three
 three hundred and ninety-four
 three hundred and ninety-five
 three hundred and ninety-six
 three hundred and ninety-seven
 three hundred and ninety-eight
 three hundred and ninety-nine
 four hundred
 four hundred and one
 four hundred and two
 four hundred and three
 four hundred and four
 four hundred and five
 four hundred and six
 four hundred and seven
 four hundred and eight
 four hundred and nine
 four hundred and ten
 four hundred and eleven
 four hundred and twelve
 four hundred and thirteen
 four hundred and fourteen
 four hundred and fifteen
 four hundred and sixteen
 four hundred and seventeen
 four hundred and eighteen
 four hundred and nineteen
 four hundred and twenty
 four hundred and twenty-one
 four hundred and twenty-two
 four hundred and twenty-three
 four hundred and twenty-four
 four hundred and twenty-five
 four hundred and twenty-six
 four hundred and twenty-seven
 four hundred and twenty-eight
 four hundred and twenty-nine
 four hundred and thirty
 four hundred and thirty-one
 four hundred and thirty-two
 four hundred and thirty-three
 four hundred and thirty-four
 four hundred and thirty-five
 four hundred and thirty-six
 four hundred and thirty-seven
 four hundred and thirty-eight
 four hundred and thirty-nine
 four hundred and forty
 four hundred and forty-one
 four hundred and forty-two
 four hundred and forty-three
 four hundred and forty-four
 four hundred and forty-five
 four hundred and forty-six
 four hundred and forty-seven
 four hundred and forty-eight
 four hundred and forty-nine
 four hundred and fifty
 four hundred and fifty-one
 four hundred and fifty-two
 four hundred and fifty-three
 four hundred and fifty-four
 four hundred and fifty-five
 four hundred and fifty-six
 four hundred and fifty-seven
 four hundred and fifty-eight
 four hundred and fifty-nine
 four hundred and sixty
 four hundred and sixty-one
 four hundred and sixty-two
 four hundred and sixty-three
 four hundred and sixty-four
 four hundred and sixty-five
 four hundred and sixty-six
 four hundred and sixty-seven
 four hundred and sixty-eight
 four hundred and sixty-nine
 four hundred and seventy
 four hundred and seventy-one
 four hundred and seventy-two
 four hundred and seventy-three
 four hundred and seventy-four
 four hundred and seventy-five
 four hundred and seventy-six
 four hundred and seventy-seven
 four hundred and seventy-eight
 four hundred and seventy-nine
 four hundred and eighty
 four hundred and eighty-one
 four hundred and eighty-two
 four hundred and eighty-three
 four hundred and eighty-four
 four hundred and eighty-five
 four hundred and eighty-six
 four hundred and eighty-seven
 four hundred and eighty-eight
 four hundred and eighty-nine
 four hundred and ninety
 four hundred and ninety-one
 four hundred and ninety-two
 four hundred and ninety-three
 four hundred and ninety-four
 four hundred and ninety-five
 four hundred and ninety-six
 four hundred and ninety-seven
 four hundred and ninety-eight
 four hundred and ninety-nine
 five hundred
 five hundred and one
 five hundred and two
 five hundred and three
 five hundred and four
 five hundred and five
 five hundred and six
 five hundred and seven
 five hundred and eight
 five hundred and nine
 five hundred and ten
 five hundred and eleven
 five hundred and twelve
 five hundred and thirteen
 five hundred and fourteen
 five hundred and fifteen
 five hundred and sixteen
 five hundred and seventeen
 five hundred and eighteen
 five hundred and nineteen
 five hundred and twenty
 five hundred and twenty-one
 five hundred and twenty-two
 five hundred and twenty-three
 five hundred and twenty-four
 five hundred and twenty-five
 five hundred and twenty-six
 five hundred and twenty-seven
 five hundred and twenty-eight
 five hundred and twenty-nine
 five hundred and thirty
 five hundred and thirty-one
 five hundred and thirty-two
 five hundred and thirty-three
 five hundred and thirty-four
 five hundred and thirty-five
 five hundred and thirty-six
 five hundred and thirty-seven
 five hundred and thirty-eight
 five hundred and thirty-nine
 five hundred and forty
 five hundred and forty-one
 five hundred and forty-two
 five hundred and forty-three
 five hundred and forty-four
 five hundred and forty-five
 five hundred and forty-six
 five hundred and forty-seven
 five hundred and forty-eight
 five hundred and forty-nine
 five hundred and fifty
 five hundred and fifty-one
 five hundred and fifty-two
 five hundred and fifty-three
 five hundred and fifty-four
 five hundred and fifty-five
 five hundred and fifty-six
 five hundred and fifty-seven
 five hundred and fifty-eight
 five hundred and fifty-nine
 five hundred and sixty
 five hundred and sixty-one
 five hundred and sixty-two
 five hundred and sixty-three
 five hundred and sixty-four
 five hundred and sixty-five
 five hundred and sixty-six
 five hundred and sixty-seven
 five hundred and sixty-eight
 five hundred and sixty-nine
 five hundred and seventy
 five hundred and seventy-one
 five hundred and seventy-two
 five hundred and seventy-three
 five hundred and seventy-four
 five hundred and seventy-five
 five hundred and seventy-six
 five hundred and seventy-seven
 five hundred and seventy-eight
 five hundred and seventy-nine
 five hundred and eighty
 five hundred and eighty-one
 five hundred and eighty-two
 five hundred and eighty-three
 five hundred and eighty-four
 five hundred and eighty-five
 five hundred and eighty-six
 five hundred and eighty-seven
 five hundred and eighty-eight
 five hundred and eighty-nine
 five hundred and ninety
 five hundred and ninety-one
 five hundred and ninety-two
 five hundred and ninety-three
 five hundred and ninety-four
 five hundred and ninety-five
 five hundred and ninety-six
 five hundred and ninety-seven
 five hundred and ninety-eight
 five hundred and ninety-nine
 six hundred
 six hundred and one
 six hundred and two
 six hundred and three
 six hundred and four
 six hundred and five
 six hundred and six
 six hundred and seven
 six hundred and eight
 six hundred and nine
 six hundred and ten
 six hundred and eleven
 six hundred and twelve
 six hundred and thirteen
 six hundred and fourteen
 six hundred and fifteen
 six hundred and sixteen
 six hundred and seventeen
 six hundred and eighteen
 six hundred and nineteen
 six hundred and twenty
 six hundred and twenty-one
 six hundred and twenty-two
 six hundred and twenty-three
 six hundred and twenty-four
 six hundred and twenty-five
 six hundred and twenty-six
 six hundred and twenty-seven
 six hundred and twenty-eight
 six hundred and twenty-nine
 six hundred and thirty
 six hundred and thirty-one
 six hundred and thirty-two
 six hundred and thirty-three
 six hundred and thirty-four
 six hundred and thirty-five
 six hundred and thirty-six
 six hundred and thirty-seven
 six hundred and thirty-eight
 six hundred and thirty-nine
 six hundred and forty
 six hundred and forty-one
 six hundred and forty-two
 six hundred and forty-three
 six hundred and forty-four
 six hundred and forty-five
 six hundred and forty-six
 six hundred and forty-seven
 six hundred and forty-eight
 six hundred and forty-nine
 six hundred and fifty
 six hundred and fifty-one
 six hundred and fifty-two
 six hundred and fifty-three
 six hundred and fifty-four
 six hundred and fifty-five
 six hundred and fifty-six
 /*  SPDX - License - Identifier :  GPL -2.0  */
 /*
  *	 header.S
  *
  *	 Copyright ( C )  one thousand nine hundred and ninety-one ,  one thousand nine hundred and ninety-two  Linus  Torvalds
  *
  *	 Based  on  bootsect.S  and  setup.S
  *	 modified  by  more  people  than  can  be  counted
  *
  *	 Rewritten  as  a  common  file  by  H.  Peter  Anvin ( Apr  two thousand and seven )
  *
  *  BIG  FAT  NOTE :  We ' re in real mode using 64k segments.  Therefore segment
  *  addresses  must  be  multiplied  by  sixteen  to  obtain  their  respective  linear
  *  addresses.  To  avoid  confusion ,  linear  addresses  are  written  using  leading
  *  hex  while  segment  addresses  are  written  as  segment : offset.
  *
  */
 #include < linux/pe.h >
 #include <asm/segment.h>
 #include <asm/boot.h>
 #include <asm/page_types.h>
 #include <asm/setup.h>
 #include <asm/bootparam.h>
 #include " boot.h "
 #include " voffset.h "
 #include " zoffset.h "

 BOOTSEG		 =  0x07C0		 /*  original  address  of  boot - sector  */
 SYSSEG		 =  0x1000		 /*  historical  load  address  >>  four  */

 #ifndef SVGA_MODE
 #define SVGA_MODE  ASK_VGA
 #endif

 #ifndef ROOT_RDONLY
 #define ROOT_RDONLY one
 #endif

	 . code16
	 . section  ".bstext" ,  "ax"

	 . global  bootsect_start
 bootsect_start :
 #ifdef CONFIG_EFI_STUB
	 # "MZ", MS -DOS header
	 . word	 MZ_MAGIC
 #endif

	 # Normalize the start address
	 ljmp	 $ BOOTSEG ,  $ start2

 start2 :
	 movw	 % cs , % ax
	 movw	 % ax , % ds
	 movw	 % ax , % es
	 movw	 % ax , % ss
	 xorw	 % sp , % sp
	 sti
	 cld

	 movw	 $ bugger_off_msg ,  % si

 msg_loop :
 lodsb
 andb	% al ,  % al
 jz bs_die
 movb	$0xe, % ah
	 movw	 $ seven ,  % bx
 int	$0x10
	 jmp	 msg_loop

 bs_die :
 # Allow the  user  to  press a key , then  reboot
 xorw	% ax ,  % ax
 int	$0x16
 int	$0x19

 # int 0x19 should never return.  In case it  does anyway,
 # invoke  the  BIOS  reset  code ...
 ljmp	$0xf000,$0xfff0

 #ifdef CONFIG_EFI_STUB
 . org 0x3c
 #
 # Offset  to  the  PE  header .
 #
 .long pe_header
 #endif /* CONFIG_EFI_STUB */

 . section ".bsdata", "a"
 bugger_off_msg :
 . ascii "Use a boot loader.\r\n"
 . ascii "\n"
 . ascii "Remove disk and press any key to reboot...\r\n"
 . byte zero

 #ifdef CONFIG_EFI_STUB
 pe_header :
 .long PE_MAGIC

 coff_header :
 #ifdef CONFIG_X86_32
 . set	 image_file_add_flags , IMAGE_FILE_32BIT_MACHINE
 . set	 pe_opt_magic , PE_OPT_MAGIC_PE32
 . word	 IMAGE_FILE_MACHINE_I386
 #else
 . set	 image_file_add_flags , 0
 . set	 pe_opt_magic , PE_OPT_MAGIC_PE32PLUS
 . word	 IMAGE_FILE_MACHINE_AMD64
 #endif
 . word	 section_count # nr_sections
 .long	0 				# TimeDateStamp
 .long	0				# PointerToSymbolTable
 .long	1				# NumberOfSymbols
 . word	 section_table - optional_header # SizeOfOptionalHeader
 . word	 IMAGE_FILE_EXECUTABLE_IMAGE | \
		 image_file_add_flags | \
		 IMAGE_FILE_DEBUG_STRIPPED | \
		 IMAGE_FILE_LINE_NUMS_STRIPPED # Characteristics

 optional_header :
 . word	 pe_opt_magic
 . byte 0x02				# MajorLinkerVersion
 . byte 0x14				# MinorLinkerVersion

 # Filled in  by  build .c
 .long	0				# SizeOfCode

 .long	0				# SizeOfInitializedData
 .long	0				# SizeOfUninitializedData

 # Filled in  by  build .c
 .long	0x0000				# AddressOfEntryPoint

 .long	0x0200				# BaseOfCode
 #ifdef CONFIG_X86_32
 .long	0				# data
 #endif

 extra_header_fields :
 # PE  specification requires ImageBase to  be 64k aligned
 . set	 image_base , (LOAD_PHYSICAL_ADDR + 0xffff) & ~0xffff
 #ifdef CONFIG_X86_32
 .long image_base # ImageBase
 #else
 . quad	 image_base # ImageBase
 #endif
 .long	0x20				# SectionAlignment
 .long	0x20				# FileAlignment
 . word 0				# MajorOperatingSystemVersion
 . word 0				# MinorOperatingSystemVersion
 . word	 LINUX_EFISTUB_MAJOR_VERSION # MajorImageVersion
 . word	 LINUX_EFISTUB_MINOR_VERSION # MinorImageVersion
 . word 0				# MajorSubsystemVersion
 . word 0				# MinorSubsystemVersion
 .long	0				# Win32VersionValue

 #
 # The size of  the bzImage is  written  in  tools / build .c
 #
 .long	0				# SizeOfImage

 .long	0x200				# SizeOfHeaders
 .long	0				# CheckSum
 . word	 IMAGE_SUBSYSTEM_EFI_APPLICATION # Subsystem (EFI application )
 . word 0				# DllCharacteristics
 #ifdef CONFIG_X86_32
 .long	0				# SizeOfStackReserve
 .long	0				# SizeOfStackCommit
 .long	0				# SizeOfHeapReserve
 .long	0				# SizeOfHeapCommit
 #else
 . quad 0				# SizeOfStackReserve
 . quad 0				# SizeOfStackCommit
 . quad 0				# SizeOfHeapReserve
 . quad 0				# SizeOfHeapCommit
 #endif
 .long	0				# LoaderFlags
 .long	( section_table - .) /  8		# NumberOfRvaAndSizes

 . quad 0				# ExportTable
 . quad 0				# ImportTable
 . quad 0				# ResourceTable
 . quad 0				# ExceptionTable
 . quad 0				# CertificationTable
 . quad 0				# BaseRelocationTable

 # Section  table
 section_table :
 #
 # The offset & size fields are filled  in  by  build .c.
 #
 . ascii ".setup"
 . byte zero
 . byte zero
 .long	0
 .long	0x0				# startup_{32,64}
 .long	0				# Size  of  initialized data
 # on  disk
 .long	0x0				# startup_{32,64}
 .long	0				# PointerToRelocations
 .long	0				# PointerToLineNumbers
 . word 0				# NumberOfRelocations
 . word 0				# NumberOfLineNumbers
 .long IMAGE_SCN_CNT_CODE | \
		 IMAGE_SCN_MEM_READ | \
		 IMAGE_SCN_MEM_EXECUTE | \
		 IMAGE_SCN_ALIGN_16BYTES # Characteristics

 #
 # The EFI application  loader requires a relocation section
 # because EFI applications must be relocatable. The . reloc
 # offset & size fields are filled  in  by  build .c.
 #
 . ascii ".reloc"
 . byte zero
 . byte zero
 .long	0
 .long	0
 .long	0				# SizeOfRawData
 .long	0				# PointerToRawData
 .long	0				# PointerToRelocations
 .long	0				# PointerToLineNumbers
 . word 0				# NumberOfRelocations
 . word 0				# NumberOfLineNumbers
 .long IMAGE_SCN_CNT_INITIALIZED_DATA | \
		 IMAGE_SCN_MEM_READ | \
		 IMAGE_SCN_MEM_DISCARDABLE | \
		 IMAGE_SCN_ALIGN_1BYTES # Characteristics

 #ifdef CONFIG_EFI_MIXED
 #
 # The offset & size fields are filled  in  by  build .c.
 #
 .asciz	".compat"
 .long	0
 .long	0x0
 .long	0				# Size  of  initialized data
 # on  disk
 .long	0x0
 .long	0				# PointerToRelocations
 .long	0				# PointerToLineNumbers
 . word 0				# NumberOfRelocations
 . word 0				# NumberOfLineNumbers
 .long IMAGE_SCN_CNT_INITIALIZED_DATA | \
		 IMAGE_SCN_MEM_READ | \
		 IMAGE_SCN_MEM_DISCARDABLE | \
		 IMAGE_SCN_ALIGN_1BYTES # Characteristics
 #endif

 #
 # The offset & size fields are filled  in  by  build .c.
 #
 . ascii ".text"
 . byte zero
 . byte zero
 . byte zero
 .long	0
 .long	0x0				# startup_{32,64}
 .long	0				# Size  of  initialized data
 # on  disk
 .long	0x0				# startup_{32,64}
 .long	0				# PointerToRelocations
 .long	0				# PointerToLineNumbers
 . word 0				# NumberOfRelocations
 . word 0				# NumberOfLineNumbers
 .long IMAGE_SCN_CNT_CODE | \
		 IMAGE_SCN_MEM_READ | \
		 IMAGE_SCN_MEM_EXECUTE | \
		 IMAGE_SCN_ALIGN_16BYTES # Characteristics

 . set	 section_count , (. - section_table ) / 40
 #endif /* CONFIG_EFI_STUB */

 # Kernel attributes ; used  by  setup .  This is  part one of  the
 # header , from  the  old  boot  sector .

 . section ".header", "a"
 . globl	 sentinel
 sentinel :	. byte 0xff, 0xff        /* Used to detect broken loaders */

 . globl	 hdr
 hdr :
 setup_sects :	. byte 0			/* Filled in by build.c */
 root_flags :	. word  ROOT_RDONLY
 syssize :	.long 0			/* Filled in by build.c */
 ram_size :	. word 0			/* Obsolete */
 vid_mode :	. word  SVGA_MODE
 root_dev :	. word 0			/* Filled in by build.c */
 boot_flag :	. word 0xAA55

 # offset 512, entry point

 . globl	 _start
 _start :
 # Explicitly enter  this  as  bytes , or  the assembler
 # tries  to  generate a 3- byte  jump  here , which  causes
 # everything else to  push  off  to  the  wrong offset.
 . byte 0xeb		# short (2- byte ) jump
 . byte	 start_of_setup -1f
 1:

 # Part two of  the  header , from  the  old  setup .S

 . ascii "HdrS"		# header  signature
 . word 0x020f		# header  version  number (>= 0x0105)
 # or else old loadlin-1.5 will fail )
 . globl  realmode_swtch
 realmode_swtch :	. word 0, 0		# default_switch , SETUPSEG
 start_sys_seg :	. word	 SYSSEG # obsolete  and meaningless, but just
 # in case something  decided  to "use" it
 . word	 kernel_version -512 # pointing to  kernel  version  string
 # above  section  of  header  is  compatible
 # with loadlin-1.5 ( header  v1 .5). Don't
 # change  it .

 type_of_loader :	. byte 0		# 0 means ancient bootloader , newer
 # bootloaders know to  change  this .
 # See Documentation/ x86 / boot . rst for
 # assigned  ids

 # flags, unused  bits must be  zero (RFU) bit  within  loadflags
 loadflags :
 . byte	 LOADED_HIGH # The kernel  is  to  be  loaded  high

 setup_move_size : . word 0x8000		# size to  move , when  setup  is  not
 # loaded  at 0x90000. We will move  setup
 # to 0x90000 then just before jumping
 # into the  kernel . However, only  the
 # loader knows how much data behind
 # us  also needs to  be  loaded .

 code32_start :				# here loaders can  put a different
 # start address for 32- bit  code .
 .long	0x100000	# 0x100000 = default for big  kernel

 ramdisk_image :	.long	0		# address  of  loaded  ramdisk  image
 # Here the  loader  puts  the 32- bit
 # address  where  it  loaded  the  image .
 # This only will be  read  by  the  kernel .

 ramdisk_size :	.long	0		# its size in  bytes

 bootsect_kludge :
 .long	0		# obsolete

 heap_end_ptr :	. word	 _end + STACK_SIZE -512
 # ( Header  version 0x0201 or  later )
 # space  from  here ( exclusive ) down  to
 # end of  setup  code  can  be  used  by  setup
 # for local  heap purposes.

 ext_loader_ver :
 . byte 0		# Extended boot  loader  version
 ext_loader_type :
 . byte 0		# Extended boot  loader type

 cmd_line_ptr :	.long	0		# ( Header  version 0x0202 or  later )
 # If nonzero, a 32- bit  pointer
 # to  the  kernel  command  line .
 # The command  line should be
 # located between  the start of
 # setup  and  the end of  low
 # memory (0xa0000), or  it may
 # get  overwritten  before  it
 # gets  read .  If this  field  is
 # used , there  is  no longer
 # anything magical about the
 # 0x90000 segment ; the  setup
 # can  be located anywhere in
 # low  memory 0x10000 or higher.

 initrd_addr_max : .long 0x7fffffff
 # ( Header  version 0x0203 or  later )
 # The highest  safe  address for
 # the  contents  of  an  initrd
 # The current  kernel allows up  to four GB ,
 # but leave  it  at two GB  to avoid
 # possible  bootloader  bugs .

 kernel_alignment :  .long CONFIG_PHYSICAL_ALIGN # physical addr alignment
 # required for protected mode
 # kernel
 #ifdef CONFIG_RELOCATABLE
 relocatable_kernel :    . byte one
 #else
 relocatable_kernel :    . byte zero
 #endif
 min_alignment :		. byte  MIN_KERNEL_ALIGN_LG2 # minimum  alignment

 xloadflags :
 #ifdef CONFIG_X86_64
 # define XLF0  XLF_KERNEL_64 /* 64-bit kernel */
 #else
 # define XLF0 zero
 #endif

 #if defined ( CONFIG_RELOCATABLE ) && defined ( CONFIG_X86_64 )
 /* kernel/boot_param/ramdisk could be loaded above 4g */
 # define XLF1  XLF_CAN_BE_LOADED_ABOVE_4G
 #else
 # define XLF1 zero
 #endif

 #ifdef CONFIG_EFI_STUB
 # ifdef CONFIG_EFI_MIXED
 #  define XLF23 ( XLF_EFI_HANDOVER_32 | XLF_EFI_HANDOVER_64 )
 # else
 #  ifdef CONFIG_X86_64
 #   define XLF23  XLF_EFI_HANDOVER_64 /* 64-bit EFI handover ok */
 #  else
 #   define XLF23  XLF_EFI_HANDOVER_32 /* 32-bit EFI handover ok */
 #  endif
 # endif
 #else
 # define XLF23 zero
 #endif

 #if defined ( CONFIG_X86_64 ) && defined ( CONFIG_EFI ) && defined ( CONFIG_KEXEC_CORE )
 # define XLF4  XLF_EFI_KEXEC
 #else
 # define XLF4 zero
 #endif

 #ifdef CONFIG_X86_64
 #ifdef CONFIG_X86_5LEVEL
 #define XLF56 ( XLF_5LEVEL | XLF_5LEVEL_ENABLED )
 #else
 #define XLF56  XLF_5LEVEL
 #endif
 #else
 #define XLF56 zero
 #endif

 . word  XLF0 | XLF1 | XLF23 | XLF4 | XLF56

 cmdline_size :   .long COMMAND_LINE_SIZE -1     #length of  the  command  line ,
 # added  with  boot  protocol
 # version two point zero six

 hardware_subarch :	.long 0			# subarchitecture, added  with two point zero seven
 # default to 0 for normal  x86  PC

 hardware_subarch_data :	. quad zero

 payload_offset :		.long ZO_input_data
 payload_length :		.long ZO_z_input_len

 setup_data :		. quad 0			# 64- bit  physical  pointer  to
 # single  linked list of
 # struct setup_data

 pref_address :		. quad LOAD_PHYSICAL_ADDR	# preferred  load addr

 #
 # Getting to provably safe  in - place  decompression  is  hard . Worst case
 # behaviours need  to  be analyzed. Here let's take the  decompression  of
 # a gzip- compressed  kernel  as  example , to illustrate it :
 #
 # The file  layout  of gzip compressed  kernel  is :
 #
 # magic [2]
 # method [1]
 #    flags[1]
 # timestamp [4]
 #    extraflags[1]
 # os [1]
 # compressed data blocks [N]
 # crc [4] orig_len [4]
 #
 # ...  resulting in +18 bytes  overhead  of  uncompressed data.
 #
 # (For more  information , please refer  to  RFC one thousand nine hundred and fifty-one and  RFC 1952.)
 #
 # Files divided into blocks
 # 1 bit ( last  block  flag )
 # 2 bits ( block type)
 #
 # 1 block occurs every 32K -1 bytes  or  when  there 50%  compression
 # has been achieved. The smallest  block type encoding  is  always  used .
 #
 # stored :
 #    32 bits length in  bytes .
 #
 # fixed :
 # magic  fixed  tree .
 # symbols .
 #
 # dynamic :
 # dynamic  tree  encoding .
 # symbols .
 #
 #
 # The buffer for decompression  in  place  is  the length of  the  uncompressed
 # data, plus a small  amount  extra  to  keep  the  algorithm  safe . The
 # compressed data is placed at  the end of  the buffer.  The output  pointer
 # is placed at  the start of  the buffer and  the  input  pointer  is placed
 # where  the  compressed data starts . Problems will occur when  the  output
 # pointer  overruns  the  input  pointer .
 #
 # The output  pointer  can  only  overrun  the  input  pointer if the  input
 # pointer  is  moving faster than the  output  pointer .  A condition  only
 # triggered  by data whose compressed  form  is  larger than the  uncompressed
 # form .
 #
 # The worst case at  the  block  level  is a growth of  the  compressed data
 # of five bytes  per thirty-two thousand seven hundred and sixty-seven bytes .
 #
 # The worst case internal  to a compressed  block  is very hard  to figure.
 # The worst case can  at least be bounded by having one  bit that represents
 # 32764 bytes  and  then  all  of  the  rest  of  the  bytes representing the very
 # very last  byte .
 #
 # All  of  which  is  enough  to  compute  an  amount  of  extra data that is  required
 # to  be  safe . To avoid problems at  the  block  level allocating 5 extra  bytes
 # per thirty-two thousand seven hundred and sixty-seven bytes  of data is sufficient. To avoid problems internal  to a
 # block  adding  an  extra thirty-two thousand seven hundred and sixty-seven bytes ( the  worst case uncompressed  block size)
 # is sufficient, to ensure that in  the  worst case the decompressed data for
 # block will stop  the  byte  before  the  compressed data for a block begins.
 # To avoid problems with  the  compressed data's meta  information  an  extra eighteen
 # bytes are needed .  Leading to  the  formula :
 #
 # extra_bytes = ( uncompressed_size >> 12) + 32768 + 18
 #
 # Adding 8 bytes  per 32K is a bit excessive but much easier to  calculate .
 # Adding 32768 instead of 32767 just makes for round  numbers .
 #
 # Above analysis is for decompressing gzip compressed  kernel  only . Up  to
 # now 6 different decompressor are supported  all together. And among them
 # xz stores data in  chunks  and  has  maximum  chunk  of 64K.  Hence safety
 # margin should be  updated  to  cover  all  decompressors  so that we  don 't
 # need  to deal with  each  of them separately. Please  check
 # the  description  in  lib /decompressor_xxx.c for specific  information .
 #
 # extra_bytes = ( uncompressed_size >> 12) + 65536 + 128
 #
 # LZ4 is  even worse: data that cannot be further compressed grows by 0.4%,
 # or  one  byte  per two hundred and fifty-six bytes . OTOH, we  can safely get  rid  of  the +128 as
 # the size- dependent  part  now grows so  fast .
 #
 # extra_bytes = ( uncompressed_size >> 8) + 65536
 #
 # ZSTD compressed data grows by  at  most three bytes  per 128K, and  only  has a 22
 # byte  fixed  overhead but has a maximum  block size of 128K, so  it needs a
 # larger  margin .
 #
 # extra_bytes = ( uncompressed_size >> 8) + 131072

 #define ZO_z_extra_bytes ((ZO_z_output_len >> 8) + 131072)
 #if ZO_z_output_len > ZO_z_input_len
 # define ZO_z_extract_offset (ZO_z_output_len + ZO_z_extra_bytes - \
				  ZO_z_input_len )
 #else
 # define ZO_z_extract_offset	 ZO_z_extra_bytes
 #endif

 /*
  *  The  extract_offset  has  to  be  bigger  than  ZO  head  section.  Otherwise  when
  *  the  head  code  is  running  to  move  ZO  to  the  end  of  the  buffer ,  it  will
  *  overwrite  the  head  code  itself.
  */
 #if (ZO__ehead - ZO_startup_32) > ZO_z_extract_offset
 # define ZO_z_min_extract_offset ((ZO__ehead - ZO_startup_32 + 4095) & ~4095)
 #else
 # define ZO_z_min_extract_offset (( ZO_z_extract_offset + 4095) & ~4095)
 #endif

 #define ZO_INIT_SIZE (ZO__end - ZO_startup_32 + ZO_z_min_extract_offset )

 #define VO_INIT_SIZE (VO__end - VO__text)
 #if ZO_INIT_SIZE > VO_INIT_SIZE
 # define INIT_SIZE  ZO_INIT_SIZE
 #else
 # define INIT_SIZE  VO_INIT_SIZE
 #endif

 init_size :		 .long  INIT_SIZE		 # kernel initialization size
 handover_offset :	 .long  zero			 # Filled in  by  build .c
 kernel_info_offset :	 .long  zero			 # Filled in  by  build .c

 # End  of  setup  header #####################################################

	 . section  ".entrytext" ,  "ax"
 start_of_setup :
 # Force % es = % ds
	 movw	 % ds , % ax
	 movw	 % ax , % es
	 cld

 # Apparently some ancient versions  of LILO invoked  the  kernel  with % ss != % ds ,
 # which happened to  work  by accident for the  old  code .  Recalculate the  stack
 # pointer if % ss  is  invalid .  Otherwise leave  it alone, LOADLIN sets  up  the
 # stack behind its  own  code , so  we  can 't blindly put  it directly past the  heap .

	 movw	 % ss , % dx
	 cmpw	 % ax , % dx	 # % ds == % ss ?
	 movw	 % sp , % dx
	 je	 two f		 # -> assume % sp  is reasonably set

	 # Invalid % ss , make up a new  stack
	 movw	 $ _end ,  % dx
 testb	$ CAN_USE_HEAP , loadflags
 jz	1f
 movw heap_end_ptr , % dx
 one :	 addw	 $ STACK_SIZE ,  % dx
 jnc	2f
 xorw	% dx ,  % dx # Prevent wraparound

 2:	# Now % dx  should  point  to  the  end  of  our  stack  space
	 andw	 $~ three ,  % dx # dword  align (might as well...)
 jnz	3f
 movw	$0xfffc, % dx	 # Make sure we ' re  not  zero
 three :	 movw	 % ax , % ss
	 movzwl	 % dx , % esp	 # Clear upper  half  of % esp
	 sti			 # Now we should have a working  stack

 # We will have  entered  with % cs = % ds +0x20, normalize % cs  so
 # it  is  on  par  with  the  other  segments .
	 pushw	 % ds
	 pushw $6f
 lretw
 6:

 # Check  signature  at end of  setup
	 cmpl $0x5a5aaa55, setup_sig
	 jne	 setup_bad

 # Zero  the  bss
 movw	$ __bss_start , % di
	 movw	 $ _end +3 ,  % cx
 xorl	% eax ,  % eax
	 subw % di ,  % cx
 shrw	$2, % cx
	 rep ;  stosl

 # Jump to C code (should not return)
	 calll	 main

 # Setup  corrupt somehow...
 setup_bad :
	 movl	 $ setup_corrupt , % eax
	 calll	 puts
	 # Fall through...

	 . globl	 die
	 .type	 die ,  @ function
 die :
	 hlt
	 jmp	 die

	 .size	 die ,  . - die

	 . section  ".initdata" ,  "a"
 setup_corrupt :
	 . byte	 seven
	 . string	 "No setup signature found...\n"