
bootblock.o:     file format elf32-i386

Disassembly of section .text:

00007c00 <start>:

.globl start
start:
  .code16                     # Assemble for 16-bit mode
  cli                         # Disable interrupts
    7c00:	fa                   	cli    
  cld                         # String operations increment
    7c01:	fc                   	cld    

  # Set up the important data segment registers (DS, ES, SS).
  xorw    %ax,%ax             # Segment number zero
    7c02:	31 c0                	xor    %eax,%eax
  movw    %ax,%ds             # -> Data Segment
    7c04:	8e d8                	movl   %eax,%ds
  movw    %ax,%es             # -> Extra Segment
    7c06:	8e c0                	movl   %eax,%es
  movw    %ax,%ss             # -> Stack Segment
    7c08:	8e d0                	movl   %eax,%ss

00007c0a <seta20.1>:

  # Enable A20:
  #   For backwards compatibility with the earliest PCs, physical
  #   address line 20 is tied low, so that addresses higher than
  #   1MB wrap around to zero by default.  This code undoes this.
seta20.1:
  inb     $0x64,%al               # Wait for not busy
    7c0a:	e4 64                	in     $0x64,%al
  testb   $0x2,%al
    7c0c:	a8 02                	test   $0x2,%al
  jnz     seta20.1
    7c0e:	75 fa                	jne    7c0a <seta20.1>

  movb    $0xd1,%al               # 0xd1 -> port 0x64
    7c10:	b0 d1                	mov    $0xd1,%al
  outb    %al,$0x64
    7c12:	e6 64                	out    %al,$0x64

00007c14 <seta20.2>:

seta20.2:
  inb     $0x64,%al               # Wait for not busy
    7c14:	e4 64                	in     $0x64,%al
  testb   $0x2,%al
    7c16:	a8 02                	test   $0x2,%al
  jnz     seta20.2
    7c18:	75 fa                	jne    7c14 <seta20.2>

  movb    $0xdf,%al               # 0xdf -> port 0x60
    7c1a:	b0 df                	mov    $0xdf,%al
  outb    %al,$0x60
    7c1c:	e6 60                	out    %al,$0x60

  # Switch from real to protected mode, using a bootstrap GDT
  # and segment translation that makes virtual addresses 
  # identical to physical addresses, so that the 
  # effective memory map does not change during the switch.
  lgdt    gdtdesc
    7c1e:	0f 01 16             	lgdtl  (%esi)
    7c21:	64                   	fs
    7c22:	7c 0f                	jl     7c33 <protcseg+0x1>
  movl    %cr0, %eax
    7c24:	20 c0                	and    %al,%al
  orl     $CR0_PE_ON, %eax
    7c26:	66 83 c8 01          	or     $0x1,%ax
  movl    %eax, %cr0
    7c2a:	0f 22 c0             	mov    %eax,%cr0
  
  # Jump to next instruction, but in 32-bit code segment.
  # Switches processor into 32-bit mode.
  ljmp    $PROT_MODE_CSEG, $protcseg
    7c2d:	ea 32 7c 08 00 66 b8 	ljmp   $0xb866,$0x87c32

00007c32 <protcseg>:

  .code32                     # Assemble for 32-bit mode
protcseg:
  # Set up the protected-mode data segment registers
  movw    $PROT_MODE_DSEG, %ax    # Our data segment selector
    7c32:	66 b8 10 00          	mov    $0x10,%ax
  movw    %ax, %ds                # -> DS: Data Segment
    7c36:	8e d8                	movl   %eax,%ds
  movw    %ax, %es                # -> ES: Extra Segment
    7c38:	8e c0                	movl   %eax,%es
  movw    %ax, %fs                # -> FS
    7c3a:	8e e0                	movl   %eax,%fs
  movw    %ax, %gs                # -> GS
    7c3c:	8e e8                	movl   %eax,%gs
  movw    %ax, %ss                # -> SS: Stack Segment
    7c3e:	8e d0                	movl   %eax,%ss
  
  # Set up the stack pointer and call into C.
  movl    $start, %esp
    7c40:	bc 00 7c 00 00       	mov    $0x7c00,%esp
  call    bootmain
    7c45:	e8 e1 00 00 00       	call   7d2b <bootmain>

00007c4a <spin>:

  # If bootmain returns (it shouldn't), loop.
spin:
  jmp     spin
    7c4a:	eb fe                	jmp    7c4a <spin>

00007c4c <gdt>:
	...
    7c54:	ff                   	(bad)  
    7c55:	ff 00                	incl   (%eax)
    7c57:	00 00                	add    %al,(%eax)
    7c59:	9a cf 00 ff ff 00 00 	lcall  $0x0,$0xffff00cf
    7c60:	00 92 cf 00 17 00    	add    %dl,0x1700cf(%edx)

00007c64 <gdtdesc>:
    7c64:	17                   	pop    %ss
    7c65:	00 4c 7c 00          	add    %cl,0x0(%esp,%edi,2)
    7c69:	00 90 90 55 89 e5    	add    %dl,0xe5895590(%eax)

00007c6c <waitdisk>:
}

void
waitdisk(void)
{
    7c6c:	55                   	push   %ebp
    7c6d:	89 e5                	mov    %esp,%ebp
    7c6f:	ba f7 01 00 00       	mov    $0x1f7,%edx
inb(ushort port)
{
  uchar data;

  asm volatile("in %1,%0" : "=a" (data) : "d" (port));
    7c74:	ec                   	in     (%dx),%al
  // Wait for disk ready.
  while((inb(0x1F7) & 0xC0) != 0x40)
    7c75:	0f b6 c0             	movzbl %al,%eax
    7c78:	25 c0 00 00 00       	and    $0xc0,%eax
    7c7d:	83 f8 40             	cmp    $0x40,%eax
    7c80:	75 f2                	jne    7c74 <waitdisk+0x8>
    ;
}
    7c82:	5d                   	pop    %ebp
    7c83:	c3                   	ret    

00007c84 <readsect>:

// Read a single sector at offset into dst.
void
readsect(void *dst, uint offset)
{
    7c84:	55                   	push   %ebp
    7c85:	89 e5                	mov    %esp,%ebp
    7c87:	57                   	push   %edi
    7c88:	53                   	push   %ebx
    7c89:	8b 7d 08             	mov    0x8(%ebp),%edi
    7c8c:	8b 5d 0c             	mov    0xc(%ebp),%ebx
  // Issue command.
  waitdisk();
    7c8f:	e8 d8 ff ff ff       	call   7c6c <waitdisk>

static inline void
outb(ushort port, uchar data)
{
  asm volatile("out %0,%1" : : "a" (data), "d" (port));
    7c94:	b0 01                	mov    $0x1,%al
    7c96:	ba f2 01 00 00       	mov    $0x1f2,%edx
    7c9b:	ee                   	out    %al,(%dx)
  outb(0x1F2, 1);   // count = 1
  outb(0x1F3, offset);
  outb(0x1F4, offset >> 8);
  outb(0x1F5, offset >> 16);
  outb(0x1F6, (offset >> 24) | 0xE0);
  outb(0x1F7, 0x20);  // cmd 0x20 - read sectors

  // Read data.
  waitdisk();
    7c9c:	ba f3 01 00 00       	mov    $0x1f3,%edx
    7ca1:	88 d8                	mov    %bl,%al
    7ca3:	ee                   	out    %al,(%dx)
    7ca4:	0f b6 c7             	movzbl %bh,%eax
    7ca7:	ba f4 01 00 00       	mov    $0x1f4,%edx
    7cac:	ee                   	out    %al,(%dx)
    7cad:	89 d8                	mov    %ebx,%eax
    7caf:	c1 e8 10             	shr    $0x10,%eax
    7cb2:	ba f5 01 00 00       	mov    $0x1f5,%edx
    7cb7:	ee                   	out    %al,(%dx)
    7cb8:	89 d8                	mov    %ebx,%eax
    7cba:	c1 e8 18             	shr    $0x18,%eax
    7cbd:	0d e0 00 00 00       	or     $0xe0,%eax
    7cc2:	ba f6 01 00 00       	mov    $0x1f6,%edx
    7cc7:	ee                   	out    %al,(%dx)
    7cc8:	b0 20                	mov    $0x20,%al
    7cca:	ba f7 01 00 00       	mov    $0x1f7,%edx
    7ccf:	ee                   	out    %al,(%dx)
    7cd0:	e8 97 ff ff ff       	call   7c6c <waitdisk>

static inline void
insl(int port, void *addr, int cnt)
{
  asm volatile("cld\n\trepne\n\tinsl"     :
    7cd5:	ba f0 01 00 00       	mov    $0x1f0,%edx
    7cda:	b9 80 00 00 00       	mov    $0x80,%ecx
    7cdf:	fc                   	cld    
    7ce0:	f2 6d                	repnz insl (%dx),%es:(%edi)
  insl(0x1F0, dst, SECTSIZE/4);
}
    7ce2:	5b                   	pop    %ebx
    7ce3:	5f                   	pop    %edi
    7ce4:	5d                   	pop    %ebp
    7ce5:	c3                   	ret    

00007ce6 <readseg>:

// Read 'count' bytes at 'offset' from kernel into virtual address 'va'.
// Might copy more than asked.
void
readseg(uint va, uint count, uint offset)
{
    7ce6:	55                   	push   %ebp
    7ce7:	89 e5                	mov    %esp,%ebp
    7ce9:	57                   	push   %edi
    7cea:	56                   	push   %esi
    7ceb:	53                   	push   %ebx
    7cec:	83 ec 08             	sub    $0x8,%esp
    7cef:	8b 45 08             	mov    0x8(%ebp),%eax
  uint eva;

  eva = va + count;
    7cf2:	89 c7                	mov    %eax,%edi
    7cf4:	03 7d 0c             	add    0xc(%ebp),%edi

  // Round down to sector boundary.
  va &= ~(SECTSIZE - 1);
    7cf7:	89 c6                	mov    %eax,%esi
    7cf9:	81 e6 00 fe ff ff    	and    $0xfffffe00,%esi

  // Translate from bytes to sectors; kernel starts at sector 1.
  offset = (offset / SECTSIZE) + 1;

  // If this is too slow, we could read lots of sectors at a time.
  // We'd write more to memory than asked, but it doesn't matter --
  // we load in increasing order.
  for(; va < eva; va += SECTSIZE, offset++)
    7cff:	39 f7                	cmp    %esi,%edi
    7d01:	76 20                	jbe    7d23 <readseg+0x3d>
    7d03:	8b 45 10             	mov    0x10(%ebp),%eax
    7d06:	c1 e8 09             	shr    $0x9,%eax
    7d09:	8d 58 01             	lea    0x1(%eax),%ebx
    readsect((uchar*)va, offset);
    7d0c:	89 5c 24 04          	mov    %ebx,0x4(%esp)
    7d10:	89 34 24             	mov    %esi,(%esp)
    7d13:	e8 6c ff ff ff       	call   7c84 <readsect>
    7d18:	81 c6 00 02 00 00    	add    $0x200,%esi
    7d1e:	43                   	inc    %ebx
    7d1f:	39 f7                	cmp    %esi,%edi
    7d21:	77 e9                	ja     7d0c <readseg+0x26>
}
    7d23:	83 c4 08             	add    $0x8,%esp
    7d26:	5b                   	pop    %ebx
    7d27:	5e                   	pop    %esi
    7d28:	5f                   	pop    %edi
    7d29:	5d                   	pop    %ebp
    7d2a:	c3                   	ret    

00007d2b <bootmain>:
    7d2b:	55                   	push   %ebp
    7d2c:	89 e5                	mov    %esp,%ebp
    7d2e:	56                   	push   %esi
    7d2f:	53                   	push   %ebx
    7d30:	83 ec 10             	sub    $0x10,%esp
    7d33:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
    7d3a:	00 
    7d3b:	c7 44 24 04 00 10 00 	movl   $0x1000,0x4(%esp)
    7d42:	00 
    7d43:	c7 04 24 00 00 01 00 	movl   $0x10000,(%esp)
    7d4a:	e8 97 ff ff ff       	call   7ce6 <readseg>
    7d4f:	81 3d 00 00 01 00 7f 	cmpl   $0x464c457f,0x10000
    7d56:	45 4c 46 
    7d59:	75 4e                	jne    7da9 <bootmain+0x7e>
    7d5b:	8b 1d 1c 00 01 00    	mov    0x1001c,%ebx
    7d61:	81 c3 00 00 01 00    	add    $0x10000,%ebx
    7d67:	0f b7 05 2c 00 01 00 	movzwl 0x1002c,%eax
    7d6e:	c1 e0 05             	shl    $0x5,%eax
    7d71:	8d 34 03             	lea    (%ebx,%eax,1),%esi
    7d74:	39 f3                	cmp    %esi,%ebx
    7d76:	73 25                	jae    7d9d <bootmain+0x72>
    7d78:	8b 43 04             	mov    0x4(%ebx),%eax
    7d7b:	89 44 24 08          	mov    %eax,0x8(%esp)
    7d7f:	8b 43 14             	mov    0x14(%ebx),%eax
    7d82:	89 44 24 04          	mov    %eax,0x4(%esp)
    7d86:	8b 43 08             	mov    0x8(%ebx),%eax
    7d89:	25 ff ff ff 00       	and    $0xffffff,%eax
    7d8e:	89 04 24             	mov    %eax,(%esp)
    7d91:	e8 50 ff ff ff       	call   7ce6 <readseg>
    7d96:	83 c3 20             	add    $0x20,%ebx
    7d99:	39 de                	cmp    %ebx,%esi
    7d9b:	77 db                	ja     7d78 <bootmain+0x4d>
    7d9d:	a1 18 00 01 00       	mov    0x10018,%eax
    7da2:	25 ff ff ff 00       	and    $0xffffff,%eax
    7da7:	ff d0                	call   *%eax

static inline void
outw(ushort port, ushort data)
{
  asm volatile("out %0,%1" : : "a" (data), "d" (port));
    7da9:	b8 00 8a ff ff       	mov    $0xffff8a00,%eax
    7dae:	ba 00 8a ff ff       	mov    $0xffff8a00,%edx
    7db3:	66 ef                	out    %ax,(%dx)
    7db5:	b8 00 8e ff ff       	mov    $0xffff8e00,%eax
    7dba:	66 ef                	out    %ax,(%dx)
    7dbc:	eb fe                	jmp    7dbc <bootmain+0x91>
