iPXE
vram_settings.c
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2015 Michael Brown <mbrown@fensystems.co.uk>.
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License as
00006  * published by the Free Software Foundation; either version 2 of the
00007  * License, or any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful, but
00010  * WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00017  * 02110-1301, USA.
00018  *
00019  * You can also choose to distribute this program under the terms of
00020  * the Unmodified Binary Distribution Licence (as given in the file
00021  * COPYING.UBDL), provided that you have satisfied its requirements.
00022  */
00023 
00024 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
00025 
00026 #include <ipxe/uaccess.h>
00027 #include <ipxe/settings.h>
00028 
00029 /** @file
00030  *
00031  * Video RAM dump
00032  *
00033  */
00034 
00035 /** Video RAM base address */
00036 #define VRAM_BASE 0xb8000
00037 
00038 /** Video RAM length */
00039 #define VRAM_LEN \
00040         ( 80 /* columns */ * 25 /* rows */ * 2 /* bytes per character */ )
00041 
00042 /**
00043  * Fetch video RAM setting
00044  *
00045  * @v data              Buffer to fill with setting data
00046  * @v len               Length of buffer
00047  * @ret len             Length of setting data, or negative error
00048  */
00049 static int vram_fetch ( void *data, size_t len ) {
00050         userptr_t vram = phys_to_user ( VRAM_BASE );
00051 
00052         /* Copy video RAM */
00053         if ( len > VRAM_LEN )
00054                 len = VRAM_LEN;
00055         copy_from_user ( data, vram, 0, len );
00056 
00057         return VRAM_LEN;
00058 }
00059 
00060 /** Video RAM setting */
00061 const struct setting vram_setting __setting ( SETTING_MISC, vram ) = {
00062         .name = "vram",
00063         .description = "Video RAM",
00064         .type = &setting_type_base64,
00065         .scope = &builtin_scope,
00066 };
00067 
00068 /** Video RAM built-in setting */
00069 struct builtin_setting vram_builtin_setting __builtin_setting = {
00070         .setting = &vram_setting,
00071         .fetch = vram_fetch,
00072 };