Use C (and CPP) style comments for assembler-with-cpp sources,
for lines that start with a comment.
This commit is contained in:
parent
66956eb45e
commit
affbd94101
@ -1,33 +1,33 @@
|
||||
#
|
||||
# Copyright (c) 2000 John Baldwin
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms are freely
|
||||
# permitted provided that the above copyright notice and this
|
||||
# paragraph and the following disclaimer are duplicated in all
|
||||
# such forms.
|
||||
#
|
||||
# This software is provided "AS IS" and without any express or
|
||||
# implied warranties, including, without limitation, the implied
|
||||
# warranties of merchantability and fitness for a particular
|
||||
# purpose.
|
||||
#
|
||||
/*
|
||||
* Copyright (c) 2000 John Baldwin
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are freely
|
||||
* permitted provided that the above copyright notice and this
|
||||
* paragraph and the following disclaimer are duplicated in all
|
||||
* such forms.
|
||||
*
|
||||
* This software is provided "AS IS" and without any express or
|
||||
* implied warranties, including, without limitation, the implied
|
||||
* warranties of merchantability and fitness for a particular
|
||||
* purpose.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
# $FreeBSD$
|
||||
/*
|
||||
* This simple program is a preloader for the normal boot3 loader. It is simply
|
||||
* prepended to the beginning of a fully built and btxld'd loader. It then
|
||||
* copies the loader to the address boot2 normally loads it, emulates the
|
||||
* boot[12] environment (protected mode, a bootinfo struct, etc.), and then jumps
|
||||
* to the start of btxldr to start the boot process. This method allows a stock
|
||||
* /boot/loader to be booted over the network via PXE w/o having to write a
|
||||
* separate PXE-aware client just to load the loader.
|
||||
*/
|
||||
|
||||
#
|
||||
# This simple program is a preloader for the normal boot3 loader. It is simply
|
||||
# prepended to the beginning of a fully built and btxld'd loader. It then
|
||||
# copies the loader to the address boot2 normally loads it, emulates the
|
||||
# boot[12] environment (protected mode, a bootinfo struct, etc.), and then jumps
|
||||
# to the start of btxldr to start the boot process. This method allows a stock
|
||||
# /boot/loader to be booted over the network via PXE w/o having to write a
|
||||
# separate PXE-aware client just to load the loader.
|
||||
#
|
||||
|
||||
#
|
||||
# Memory locations.
|
||||
#
|
||||
/*
|
||||
* Memory locations.
|
||||
*/
|
||||
.set MEM_PAGE_SIZE,0x1000 # memory page size, 4k
|
||||
.set MEM_ARG,0x900 # Arguments at start
|
||||
.set MEM_ARG_BTX,0xa100 # Where we move them to so the
|
||||
@ -38,49 +38,49 @@
|
||||
.set MEM_BTX_OFFSET,MEM_PAGE_SIZE # offset of BTX in the loader
|
||||
.set MEM_BTX_CLIENT,0xa000 # where BTX clients live
|
||||
.set MEM_BIOS_KEYBOARD,0x496 # BDA byte with keyboard bit
|
||||
#
|
||||
# a.out header fields
|
||||
#
|
||||
/*
|
||||
* a.out header fields
|
||||
*/
|
||||
.set AOUT_TEXT,0x04 # text segment size
|
||||
.set AOUT_DATA,0x08 # data segment size
|
||||
.set AOUT_BSS,0x0c # zero'd BSS size
|
||||
.set AOUT_SYMBOLS,0x10 # symbol table
|
||||
.set AOUT_ENTRY,0x14 # entry point
|
||||
.set AOUT_HEADER,MEM_PAGE_SIZE # size of the a.out header
|
||||
#
|
||||
# Flags for kargs->bootflags
|
||||
#
|
||||
/*
|
||||
* Flags for kargs->bootflags
|
||||
*/
|
||||
.set KARGS_FLAGS_PXE,0x2 # flag to indicate booting from
|
||||
# PXE loader
|
||||
#
|
||||
# Boot howto bits
|
||||
#
|
||||
/*
|
||||
* Boot howto bits
|
||||
*/
|
||||
.set RB_SERIAL,0x1000 # serial console
|
||||
#
|
||||
# Segment selectors.
|
||||
#
|
||||
/*
|
||||
* Segment selectors.
|
||||
*/
|
||||
.set SEL_SDATA,0x8 # Supervisor data
|
||||
.set SEL_RDATA,0x10 # Real mode data
|
||||
.set SEL_SCODE,0x18 # PM-32 code
|
||||
.set SEL_SCODE16,0x20 # PM-16 code
|
||||
#
|
||||
# BTX constants
|
||||
#
|
||||
/*
|
||||
* BTX constants
|
||||
*/
|
||||
.set INT_SYS,0x30 # BTX syscall interrupt
|
||||
#
|
||||
# Bit in MEM_BIOS_KEYBOARD that is set if an enhanced keyboard is present
|
||||
#
|
||||
/*
|
||||
* Bit in MEM_BIOS_KEYBOARD that is set if an enhanced keyboard is present
|
||||
*/
|
||||
.set KEYBOARD_BIT,0x10
|
||||
#
|
||||
# We expect to be loaded by the BIOS at 0x7c00 (standard boot loader entry
|
||||
# point)
|
||||
#
|
||||
/*
|
||||
* We expect to be loaded by the BIOS at 0x7c00 (standard boot loader entry
|
||||
* point)
|
||||
*/
|
||||
.code16
|
||||
.globl start
|
||||
.org 0x0, 0x0
|
||||
#
|
||||
# BTX program loader for PXE network booting
|
||||
#
|
||||
/*
|
||||
* BTX program loader for PXE network booting
|
||||
*/
|
||||
start: cld # string ops inc
|
||||
xorw %ax, %ax # zero %ax
|
||||
movw %ax, %ss # setup the
|
||||
@ -95,9 +95,9 @@ start: cld # string ops inc
|
||||
pushl %ecx # save it on the stack
|
||||
movw $welcome_msg, %si # %ds:(%si) -> welcome message
|
||||
callw putstr # display the welcome message
|
||||
#
|
||||
# Setup the arguments that the loader is expecting from boot[12]
|
||||
#
|
||||
/*
|
||||
* Setup the arguments that the loader is expecting from boot[12]
|
||||
*/
|
||||
movw $bootinfo_msg, %si # %ds:(%si) -> boot args message
|
||||
callw putstr # display the message
|
||||
movw $MEM_ARG, %bx # %ds:(%bx) -> boot args
|
||||
@ -111,26 +111,28 @@ start: cld # string ops inc
|
||||
# KARGS_FLAGS_PXE
|
||||
popl 0xc(%bx) # kargs->pxeinfo = *PXENV+
|
||||
#ifdef ALWAYS_SERIAL
|
||||
#
|
||||
# set the RBX_SERIAL bit in the howto byte.
|
||||
/*
|
||||
* set the RBX_SERIAL bit in the howto byte.
|
||||
*/
|
||||
orl $RB_SERIAL, (%bx) # enable serial console
|
||||
#endif
|
||||
#ifdef PROBE_KEYBOARD
|
||||
#
|
||||
# Look at the BIOS data area to see if we have an enhanced keyboard. If not,
|
||||
# set the RBX_SERIAL bit in the howto byte.
|
||||
/*
|
||||
* Look at the BIOS data area to see if we have an enhanced keyboard. If not,
|
||||
* set the RBX_SERIAL bit in the howto byte.
|
||||
*/
|
||||
testb $KEYBOARD_BIT, MEM_BIOS_KEYBOARD # keyboard present?
|
||||
jnz keyb # yes, so skip
|
||||
orl $RB_SERIAL, (%bx) # enable serial console
|
||||
keyb:
|
||||
#endif
|
||||
#
|
||||
# Turn on the A20 address line
|
||||
#
|
||||
/*
|
||||
* Turn on the A20 address line
|
||||
*/
|
||||
callw seta20 # Turn A20 on
|
||||
#
|
||||
# Relocate the loader and BTX using a very lazy protected mode
|
||||
#
|
||||
/*
|
||||
* Relocate the loader and BTX using a very lazy protected mode
|
||||
*/
|
||||
movw $relocate_msg, %si # Display the
|
||||
callw putstr # relocation message
|
||||
movl end+AOUT_ENTRY, %edi # %edi is the destination
|
||||
@ -180,9 +182,9 @@ pm_16: movw $SEL_RDATA, %ax # Initialize
|
||||
ljmp $0,$pm_end # Long jump to clear the
|
||||
# instruction pre-fetch queue
|
||||
pm_end: sti # Turn interrupts back on now
|
||||
#
|
||||
# Copy the BTX client to MEM_BTX_CLIENT
|
||||
#
|
||||
/*
|
||||
* Copy the BTX client to MEM_BTX_CLIENT
|
||||
*/
|
||||
xorw %ax, %ax # zero %ax and set
|
||||
movw %ax, %ds # %ds and %es
|
||||
movw %ax, %es # to segment 0
|
||||
@ -191,30 +193,30 @@ pm_end: sti # Turn interrupts back on now
|
||||
movw $(btx_client_end-btx_client), %cx # length of btx client
|
||||
rep # Relocate the
|
||||
movsb # simple BTX client
|
||||
#
|
||||
# Copy the boot[12] args to where the BTX client can see them
|
||||
#
|
||||
/*
|
||||
* Copy the boot[12] args to where the BTX client can see them
|
||||
*/
|
||||
movw $MEM_ARG, %si # where the args are at now
|
||||
movw $MEM_ARG_BTX, %di # where the args are moving to
|
||||
movw $(MEM_ARG_SIZE/4), %cx # size of the arguments in longs
|
||||
rep # Relocate
|
||||
movsl # the words
|
||||
#
|
||||
# Save the entry point so the client can get to it later on
|
||||
#
|
||||
/*
|
||||
* Save the entry point so the client can get to it later on
|
||||
*/
|
||||
movl end+AOUT_ENTRY, %eax # load the entry point
|
||||
stosl # add it to the end of the
|
||||
# arguments
|
||||
#
|
||||
# Now we just start up BTX and let it do the rest
|
||||
#
|
||||
/*
|
||||
* Now we just start up BTX and let it do the rest
|
||||
*/
|
||||
movw $jump_message, %si # Display the
|
||||
callw putstr # jump message
|
||||
ljmp $0,$MEM_BTX_ENTRY # Jump to the BTX entry point
|
||||
|
||||
#
|
||||
# Display a null-terminated string
|
||||
#
|
||||
/*
|
||||
* Display a null-terminated string
|
||||
*/
|
||||
putstr: lodsb # load %al from %ds:(%si)
|
||||
testb %al,%al # stop at null
|
||||
jnz putc # if the char != null, output it
|
||||
@ -224,9 +226,9 @@ putc: movw $0x7,%bx # attribute for output
|
||||
int $0x10 # call BIOS, print char in %al
|
||||
jmp putstr # keep looping
|
||||
|
||||
#
|
||||
# Enable A20
|
||||
#
|
||||
/*
|
||||
* Enable A20
|
||||
*/
|
||||
seta20: cli # Disable interrupts
|
||||
seta20.1: inb $0x64,%al # Get status
|
||||
testb $0x2,%al # Busy?
|
||||
@ -241,9 +243,9 @@ seta20.2: inb $0x64,%al # Get status
|
||||
sti # Enable interrupts
|
||||
retw # To caller
|
||||
|
||||
#
|
||||
# BTX client to start btxldr
|
||||
#
|
||||
/*
|
||||
* BTX client to start btxldr
|
||||
*/
|
||||
.code32
|
||||
btx_client: movl $(MEM_ARG_BTX-MEM_BTX_CLIENT+MEM_ARG_SIZE-4), %esi
|
||||
# %ds:(%esi) -> end
|
||||
@ -263,18 +265,18 @@ btx_client_end:
|
||||
.code16
|
||||
|
||||
.p2align 4
|
||||
#
|
||||
# Global descriptor table.
|
||||
#
|
||||
/*
|
||||
* Global descriptor table.
|
||||
*/
|
||||
gdt: .word 0x0,0x0,0x0,0x0 # Null entry
|
||||
.word 0xffff,0x0,0x9200,0xcf # SEL_SDATA
|
||||
.word 0xffff,0x0,0x9200,0x0 # SEL_RDATA
|
||||
.word 0xffff,0x0,0x9a00,0xcf # SEL_SCODE (32-bit)
|
||||
.word 0xffff,0x0,0x9a00,0x8f # SEL_SCODE16 (16-bit)
|
||||
gdt.1:
|
||||
#
|
||||
# Pseudo-descriptors.
|
||||
#
|
||||
/*
|
||||
* Pseudo-descriptors.
|
||||
*/
|
||||
gdtdesc: .word gdt.1-gdt-1 # Limit
|
||||
.long gdt # Base
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user