1 /* Copyright (C) 2006 Michael Brown <mbrown@fensystems.co.uk>.
3 * This program is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU General Public License as
5 * published by the Free Software Foundation; either version 2 of the
6 * License, or any later version.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 * A hidden region of Etherboot
24 * This represents a region that will be edited out of the system's
27 * This structure is accessed by assembly code, so must not be
30 struct hidden_region {
31 /* Physical start address */
33 /* Physical end address */
37 /* Linker-defined symbols */
41 /** Assembly routine in e820mangler.S */
44 /** Vector for storing original INT 15 handler */
45 extern struct segoff __text16 ( int15_vector );
46 #define int15_vector __use_text16 ( int15_vector )
49 * Unique IDs for hidden regions
57 * List of hidden regions
59 * Must be terminated by a zero entry.
61 struct hidden_region __data16_array ( hidden_regions, [] ) = {
63 [BASEMEM] = { 0, ( 640 * 1024 ) },
64 { 0, 0, } /* Terminator */
66 #define hidden_regions __use_data16 ( hidden_regions )
71 * Installs an INT 15 handler to edit Etherboot out of the memory map
72 * returned by the BIOS.
74 void hide_etherboot ( void ) {
75 hidden_regions[TEXT].start = virt_to_phys ( _text );
76 hidden_regions[TEXT].end = virt_to_phys ( _end );
77 hidden_regions[BASEMEM].start = ( rm_cs << 4 );
79 DBG ( "Hiding [%lx,%lx) and [%lx,%lx)\n",
80 ( unsigned long ) hidden_regions[TEXT].start,
81 ( unsigned long ) hidden_regions[TEXT].end,
82 ( unsigned long ) hidden_regions[BASEMEM].start,
83 ( unsigned long ) hidden_regions[BASEMEM].end );
85 hook_bios_interrupt ( 0x15, ( unsigned int ) int15,
92 * Uninstalls the INT 15 handler installed by hide_etherboot(), if
95 void unhide_etherboot ( void ) {
96 unhook_bios_interrupt ( 0x15, ( unsigned int ) int15,