Initial revision

This commit is contained in:
okuji 2002-12-27 08:53:07 +00:00
commit 6a161fa938
80 changed files with 23264 additions and 0 deletions

28
include/grub/boot.h Normal file
View file

@ -0,0 +1,28 @@
/*
* PUPA -- Preliminary Universal Programming Architecture for GRUB
* Copyright (C) 2002 Yoshinori K. Okuji <okuji@enbug.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef PUPA_BOOT_HEADER
#define PUPA_BOOT_HEADER 1
#define PUPA_BOOT_VERSION_MAJOR 4
#define PUPA_BOOT_VERSION_MINOR 0
#define PUPA_BOOT_VERSION ((PUPA_BOOT_VERSION_MINOR << 8) \
| PUPA_BOOT_VERSION_MAJOR)
#endif /* ! PUPA_BOOT_HEADER */

44
include/grub/device.h Normal file
View file

@ -0,0 +1,44 @@
/* device.h - device manager */
/*
* PUPA -- Preliminary Universal Programming Architecture for GRUB
* Copyright (C) 2002 Yoshinori K. Okuji <okuji@enbug.org>
*
* PUPA is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PUPA; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef PUPA_DEVICE_HEADER
#define PUPA_DEVICE_HEADER 1
#include <pupa/symbol.h>
#include <pupa/err.h>
struct pupa_disk;
struct pupa_net;
struct pupa_fs;
struct pupa_device
{
struct pupa_disk *disk;
struct pupa_net *net;
};
typedef struct pupa_device *pupa_device_t;
pupa_device_t EXPORT_FUNC(pupa_device_open) (const char *name);
pupa_err_t EXPORT_FUNC(pupa_device_close) (pupa_device_t device);
pupa_err_t EXPORT_FUNC(pupa_device_set_root) (const char *name);
const char *EXPORT_FUNC(pupa_device_get_root) (void);
#endif /* ! PUPA_DEVICE_HEADER */

119
include/grub/disk.h Normal file
View file

@ -0,0 +1,119 @@
/*
* PUPA -- Preliminary Universal Programming Architecture for GRUB
* Copyright (C) 2002 Yoshinori K. Okuji <okuji@enbug.org>
*
* PUPA is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PUPA; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef PUPA_DISK_HEADER
#define PUPA_DISK_HEADER 1
#include <pupa/symbol.h>
#include <pupa/err.h>
#include <pupa/types.h>
struct pupa_disk;
/* Disk device. */
struct pupa_disk_dev
{
/* The device name. */
const char *name;
/* Call HOOK with each device name, until HOOK returns non-zero. */
int (*iterate) (int (*hook) (const char *name));
/* Open the device named NAME, and set up DISK. */
pupa_err_t (*open) (const char *name, struct pupa_disk *disk);
/* Close the disk DISK. */
void (*close) (struct pupa_disk *disk);
/* Read SIZE sectors from the sector SECTOR of the disk DISK into BUF. */
pupa_err_t (*read) (struct pupa_disk *disk, unsigned long sector,
unsigned long size, char *buf);
/* Write SIZE sectors from BUF into the sector SECTOR of the disk DISK. */
pupa_err_t (*write) (struct pupa_disk *disk, unsigned long sector,
unsigned long size, const char *buf);
/* The next disk device. */
struct pupa_disk_dev *next;
};
typedef struct pupa_disk_dev *pupa_disk_dev_t;
struct pupa_partition;
/* Disk. */
struct pupa_disk
{
/* The disk name. */
const char *name;
/* The underlying disk device. */
pupa_disk_dev_t dev;
/* The total number of sectors. */
unsigned long total_sectors;
/* If partitions can be stored. */
int has_partitions;
/* The id used by the disk cache manager. */
unsigned long id;
/* The partition information. This is machine-specific. */
struct pupa_partition *partition;
/* Called when a sector was read. */
void (*read_hook) (unsigned long sector, unsigned offset, unsigned length);
/* Device-specific data. */
void *data;
};
typedef struct pupa_disk *pupa_disk_t;
/* The sector size. */
#define PUPA_DISK_SECTOR_SIZE 0x200
#define PUPA_DISK_SECTOR_BITS 9
/* The maximum number of disk caches. */
#define PUPA_DISK_CACHE_NUM 1021
/* The size of a disk cache in sector units. */
#define PUPA_DISK_CACHE_SIZE 8
#define PUPA_DISK_CACHE_BITS 3
/* This is called from the memory manager. */
void pupa_disk_cache_invalidate_all (void);
void EXPORT_FUNC(pupa_disk_dev_register) (pupa_disk_dev_t dev);
void EXPORT_FUNC(pupa_disk_dev_unregister) (pupa_disk_dev_t dev);
void EXPORT_FUNC(pupa_disk_dev_iterate) (int (*hook) (const char *name));
pupa_disk_t EXPORT_FUNC(pupa_disk_open) (const char *name);
void EXPORT_FUNC(pupa_disk_close) (pupa_disk_t disk);
pupa_err_t EXPORT_FUNC(pupa_disk_read) (pupa_disk_t disk,
unsigned long sector,
unsigned long offset,
unsigned long size,
char *buf);
pupa_err_t EXPORT_FUNC(pupa_disk_write) (pupa_disk_t disk,
unsigned long sector,
unsigned long offset,
unsigned long size,
const char *buf);
#endif /* ! PUPA_DISK_HEADER */

86
include/grub/dl.h Normal file
View file

@ -0,0 +1,86 @@
/* dl.h - types and prototypes for loadable module support */
/*
* PUPA -- Preliminary Universal Programming Architecture for GRUB
* Copyright (C) 2002 Yoshinori K. Okuji <okuji@enbug.org>
*
* PUPA is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PUPA; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef PUPA_DL_H
#define PUPA_DL_H 1
#include <pupa/symbol.h>
#include <pupa/err.h>
#include <pupa/types.h>
#define PUPA_MOD_INIT \
static void pupa_mod_init (void) __attribute__ ((unused)); \
static void \
pupa_mod_init (void)
#define PUPA_MOD_FINI \
static void pupa_mod_fini (void) __attribute__ ((unused)); \
static void \
pupa_mod_fini (void)
#define PUPA_MOD_NAME(name) \
__asm__ (".section .modname,\"S\"\n.string \"" #name "\"\n.previous")
#define PUPA_MOD_DEP(name) \
__asm__ (".section .moddeps,\"S\"\n.string \"" #name "\"\n.previous")
struct pupa_dl_segment
{
struct pupa_dl_segment *next;
void *addr;
pupa_size_t size;
unsigned section;
};
typedef struct pupa_dl_segment *pupa_dl_segment_t;
struct pupa_dl;
struct pupa_dl_dep
{
struct pupa_dl_dep *next;
struct pupa_dl *mod;
};
typedef struct pupa_dl_dep *pupa_dl_dep_t;
struct pupa_dl
{
char *name;
int ref_count;
pupa_dl_dep_t dep;
pupa_dl_segment_t segment;
void (*init) (void);
void (*fini) (void);
};
typedef struct pupa_dl *pupa_dl_t;
pupa_dl_t EXPORT_FUNC(pupa_dl_load_file) (const char *filename);
pupa_dl_t EXPORT_FUNC(pupa_dl_load) (const char *name);
pupa_dl_t pupa_dl_load_core (void *addr, pupa_size_t size);
void EXPORT_FUNC(pupa_dl_unload) (pupa_dl_t mod);
pupa_dl_t EXPORT_FUNC(pupa_dl_get) (const char *name);
pupa_err_t EXPORT_FUNC(pupa_dl_register_symbol) (const char *name, void *addr,
pupa_dl_t mod);
void *EXPORT_FUNC(pupa_dl_resolve_symbol) (const char *name);
void pupa_dl_init (const char *dir);
int pupa_arch_dl_check_header (void *ehdr, pupa_size_t size);
pupa_err_t pupa_arch_dl_relocate_symbols (pupa_dl_t mod, void *ehdr);
#endif /* ! PUPA_DL_H */

2314
include/grub/elf.h Normal file

File diff suppressed because it is too large Load diff

59
include/grub/err.h Normal file
View file

@ -0,0 +1,59 @@
/* err.h - error numbers and prototypes */
/*
* PUPA -- Preliminary Universal Programming Architecture for GRUB
* Copyright (C) 2002 Yoshinori K. Okuji <okuji@enbug.org>
*
* PUPA is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PUPA; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef PUPA_ERR_HEADER
#define PUPA_ERR_HEADER 1
#include <pupa/symbol.h>
typedef enum
{
PUPA_ERR_NONE = 0,
PUPA_ERR_BAD_MODULE,
PUPA_ERR_OUT_OF_MEMORY,
PUPA_ERR_BAD_FILE_TYPE,
PUPA_ERR_FILE_NOT_FOUND,
PUPA_ERR_FILE_READ_ERROR,
PUPA_ERR_BAD_FILENAME,
PUPA_ERR_UNKNOWN_FS,
PUPA_ERR_BAD_FS,
PUPA_ERR_BAD_NUMBER,
PUPA_ERR_OUT_OF_RANGE,
PUPA_ERR_UNKNOWN_DEVICE,
PUPA_ERR_BAD_DEVICE,
PUPA_ERR_READ_ERROR,
PUPA_ERR_WRITE_ERROR,
PUPA_ERR_BAD_ARGUMENT,
PUPA_ERR_BAD_PART_TABLE,
PUPA_ERR_UNKNOWN_OS,
PUPA_ERR_BAD_OS,
PUPA_ERR_NO_KERNEL,
PUPA_ERR_NOT_IMPLEMENTED_YET,
}
pupa_err_t;
extern pupa_err_t EXPORT_VAR(pupa_errno);
extern char EXPORT_VAR(pupa_errmsg)[];
pupa_err_t EXPORT_FUNC(pupa_error) (pupa_err_t n, const char *fmt, ...);
void EXPORT_FUNC(pupa_fatal) (const char *fmt, ...) __attribute__ ((noreturn));
void EXPORT_FUNC(pupa_print_error) (void);
#endif /* ! PUPA_ERR_HEADER */

73
include/grub/file.h Normal file
View file

@ -0,0 +1,73 @@
/*
* PUPA -- Preliminary Universal Programming Architecture for GRUB
* Copyright (C) 2002 Yoshinori K. Okuji <okuji@enbug.org>
*
* PUPA is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PUPA; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef PUPA_FILE_HEADER
#define PUPA_FILE_HEADER 1
#include <pupa/types.h>
#include <pupa/err.h>
#include <pupa/device.h>
#include <pupa/fs.h>
/* File description. */
struct pupa_file
{
/* The underlying device. */
pupa_device_t device;
/* The underlying filesystem. */
pupa_fs_t fs;
/* The current offset. */
pupa_ssize_t offset;
/* The file size. */
pupa_ssize_t size;
/* Filesystem-specific data. */
void *data;
/* This is called when a sector is read. Used only for a disk device. */
void (*read_hook) (unsigned long sector, unsigned offset, unsigned length);
};
typedef struct pupa_file *pupa_file_t;
/* Get a device name from NAME. */
char *EXPORT_FUNC(pupa_file_get_device_name) (const char *name);
pupa_file_t EXPORT_FUNC(pupa_file_open) (const char *name);
pupa_ssize_t EXPORT_FUNC(pupa_file_read) (pupa_file_t file, char *buf,
pupa_ssize_t len);
pupa_ssize_t EXPORT_FUNC(pupa_file_seek) (pupa_file_t file,
pupa_ssize_t offset);
pupa_err_t EXPORT_FUNC(pupa_file_close) (pupa_file_t file);
static inline pupa_ssize_t
pupa_file_size (const pupa_file_t file)
{
return file->size;
}
static inline pupa_ssize_t
pupa_file_tell (const pupa_file_t file)
{
return file->offset;
}
#endif /* ! PUPA_FILE_HEADER */

63
include/grub/fs.h Normal file
View file

@ -0,0 +1,63 @@
/* fs.h - filesystem manager */
/*
* PUPA -- Preliminary Universal Programming Architecture for GRUB
* Copyright (C) 2002 Yoshinori K. Okuji <okuji@enbug.org>
*
* PUPA is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PUPA; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef PUPA_FS_HEADER
#define PUPA_FS_HEADER 1
#include <pupa/device.h>
#include <pupa/symbol.h>
#include <pupa/types.h>
/* Forward declaration is required, because of mutual reference. */
struct pupa_file;
/* Filesystem descriptor. */
struct pupa_fs
{
/* My name. */
const char *name;
/* Call HOOK with each file under DIR. */
pupa_err_t (*dir) (pupa_device_t device, const char *path,
int (*hook) (const char *filename, int dir));
/* Open a file named NAME and initialize FILE. */
pupa_err_t (*open) (struct pupa_file *file, const char *name);
/* Read LEN bytes data from FILE into BUF. */
pupa_ssize_t (*read) (struct pupa_file *file, char *buf, pupa_ssize_t len);
/* Close the file FILE. */
pupa_err_t (*close) (struct pupa_file *file);
/* The next filesystem. */
struct pupa_fs *next;
};
typedef struct pupa_fs *pupa_fs_t;
/* This is special, because block lists are not files in usual sense. */
extern struct pupa_fs pupa_fs_blocklist;
void EXPORT_FUNC(pupa_fs_register) (pupa_fs_t fs);
void EXPORT_FUNC(pupa_fs_unregister) (pupa_fs_t fs);
void EXPORT_FUNC(pupa_fs_iterate) (int (*hook) (const pupa_fs_t fs));
pupa_fs_t EXPORT_FUNC(pupa_fs_probe) (pupa_device_t device);
#endif /* ! PUPA_FS_HEADER */

View file

@ -0,0 +1,47 @@
/*
* PUPA -- Preliminary Universal Programming Architecture for GRUB
* Copyright (C) 2002 Yoshinori K. Okuji <okuji@enbug.org>
*
* PUPA is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PUPA; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef PUPA_BIOSDISK_MACHINE_HEADER
#define PUPA_BIOSDISK_MACHINE_HEADER 1
#define PUPA_BIOSDISK_FLAG_LBA 1
struct pupa_biosdisk_data
{
int drive;
unsigned long cylinders;
unsigned long heads;
unsigned long sectors;
unsigned long flags;
};
int pupa_biosdisk_rw_int13_extensions (int ah, int drive, void *dap);
int pupa_biosdisk_rw_standard (int ah, int drive, int coff, int hoff,
int soff, int nsec, int segment);
int pupa_biosdisk_check_int13_extensions (int drive);
int pupa_biosdisk_get_diskinfo_int13_extensions (int drive, void *drp);
int pupa_biosdisk_get_diskinfo_standard (int drive,
unsigned long *cylinders,
unsigned long *heads,
unsigned long *sectors);
int pupa_biosdisk_get_num_floppies (void);
void pupa_biosdisk_init (void);
#endif /* ! PUPA_BIOSDISK_MACHINE_HEADER */

View file

@ -0,0 +1,83 @@
/*
* PUPA -- Preliminary Universal Programming Architecture for GRUB
* Copyright (C) 1999, 2000 Free Software Foundation, Inc.
* Copyright (C) 2002 Yoshinori K. Okuji <okuji@enbug.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef PUPA_BOOT_MACHINE_HEADER
#define PUPA_BOOT_MACHINE_HEADER 1
/* The signature for bootloader. */
#define PUPA_BOOT_MACHINE_SIGNATURE 0xaa55
/* The offset of the end of BPB (BIOS Parameter Block). */
#define PUPA_BOOT_MACHINE_BPBEND 0x3e
/* The offset of the major version. */
#define PUPA_BOOT_MACHINE_VER_MAJ 0x3e
/* The offset of BOOT_DRIVE. */
#define PUPA_BOOT_MACHINE_BOOT_DRIVE 0x40
/* The offset of FORCE_LBA. */
#define PUPA_BOOT_MACHINE_FORCE_LBA 0x41
/* The offset of KERNEL_ADDRESS. */
#define PUPA_BOOT_MACHINE_KERNEL_ADDRESS 0x42
/* The offset of KERNEL_SECTOR. */
#define PUPA_BOOT_MACHINE_KERNEL_SECTOR 0x44
/* The offset of KERNEL_SEGMENT. */
#define PUPA_BOOT_MACHINE_KERNEL_SEGMENT 0x48
/* The offset of a magic number used by Windows NT. */
#define PUPA_BOOT_MACHINE_WINDOWS_NT_MAGIC 0x1b8
/* The offset of the start of the partition table. */
#define PUPA_BOOT_MACHINE_PART_START 0x1be
/* The offset of the end of the partition table. */
#define PUPA_BOOT_MACHINE_PART_END 0x1fe
/* The stack segment. */
#define PUPA_BOOT_MACHINE_STACK_SEG 0x2000
/* The segment of disk buffer. The disk buffer MUST be 32K long and
cannot straddle a 64K boundary. */
#define PUPA_BOOT_MACHINE_BUFFER_SEG 0x7000
/* The address of drive parameters. */
#define PUPA_BOOT_MACHINE_DRP_ADDR 0x7f00
/* The size of drive parameters. */
#define PUPA_BOOT_MACHINE_DRP_SIZE 0x42
/* The flag for BIOS drive number to designate a hard disk vs. a
floppy. */
#define PUPA_BOOT_MACHINE_BIOS_HD_FLAG 0x80
/* The segment where the kernel is loaded. */
#define PUPA_BOOT_MACHINE_KERNEL_SEG 0x800
/* The address where the kernel is loaded. */
#define PUPA_BOOT_MACHINE_KERNEL_ADDR (PUPA_BOOT_MACHINE_KERNEL_SEG << 4)
/* The size of a block list used in the kernel startup code. */
#define PUPA_BOOT_MACHINE_LIST_SIZE 8
#endif /* ! BOOT_MACHINE_HEADER */

View file

@ -0,0 +1,55 @@
/*
* PUPA -- Preliminary Universal Programming Architecture for GRUB
* Copyright (C) 2002 Yoshinori K. Okuji <okuji@enbug.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef PUPA_CONSOLE_MACHINE_HEADER
#define PUPA_CONSOLE_MACHINE_HEADER 1
/* Define scan codes. */
#define PUPA_CONSOLE_KEY_LEFT 0x4B00
#define PUPA_CONSOLE_KEY_RIGHT 0x4D00
#define PUPA_CONSOLE_KEY_UP 0x4800
#define PUPA_CONSOLE_KEY_DOWN 0x5000
#define PUPA_CONSOLE_KEY_IC 0x5200
#define PUPA_CONSOLE_KEY_DC 0x5300
#define PUPA_CONSOLE_KEY_BACKSPACE 0x0008
#define PUPA_CONSOLE_KEY_HOME 0x4700
#define PUPA_CONSOLE_KEY_END 0x4F00
#define PUPA_CONSOLE_KEY_NPAGE 0x4900
#define PUPA_CONSOLE_KEY_PPAGE 0x5100
#ifndef ASM_FILE
#include <pupa/types.h>
/* These are global to share code between C and asm. */
extern pupa_uint8_t pupa_console_cur_color;
void pupa_console_putchar (int c);
int pupa_console_checkkey (void);
int pupa_console_getkey (void);
pupa_uint16_t pupa_console_getxy (void);
void pupa_console_gotoxy (pupa_uint8_t x, pupa_uint8_t y);
void pupa_console_cls (void);
void pupa_console_setcursor (int on);
/* Initialize the console system. */
void pupa_console_init (void);
#endif
#endif /* ! PUPA_CONSOLE_MACHINE_HEADER */

View file

@ -0,0 +1,50 @@
/*
* PUPA -- Preliminary Universal Programming Architecture for GRUB
* Copyright (C) 2002 Yoshinori K. Okuji <okuji@enbug.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef PUPA_INIT_MACHINE_HEADER
#define PUPA_INIT_MACHINE_HEADER 1
#include <pupa/types.h>
#include <pupa/symbol.h>
/* Get the memory size in KB. If EXTENDED is zero, return conventional
memory, otherwise return extended memory. */
pupa_uint16_t pupa_get_memsize (int extended);
/* Get a packed EISA memory map. Lower 16 bits are between 1MB and 16MB
in 1KB parts, and upper 16 bits are above 16MB in 64KB parts. */
pupa_uint32_t pupa_get_eisa_mmap (void);
struct pupa_machine_mmap_entry
{
pupa_uint32_t size;
pupa_uint64_t addr;
pupa_uint64_t len;
pupa_uint32_t type;
};
/* Get a memory map entry. Return next continuation value. Zero means
the end. */
pupa_uint32_t pupa_get_mmap_entry (struct pupa_machine_mmap_entry *entry,
pupa_uint32_t cont);
/* Turn on/off Gate A20. */
void EXPORT_FUNC(pupa_gate_a20) (int on);
#endif /* ! PUPA_INIT_MACHINE_HEADER */

View file

@ -0,0 +1,29 @@
/*
* PUPA -- Preliminary Universal Programming Architecture for GRUB
* Copyright (C) 2002 Yoshinori K. Okuji <okuji@enbug.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef KERNEL_MACHINE_HEADER
#define KERNEL_MACHINE_HEADER 1
/* The offset of PUPA_TOTAL_MODULE_SIZE. */
#define PUPA_KERNEL_MACHINE_TOTAL_MODULE_SIZE 0x8
/* The offset of PUPA_KERNEL_IMAGE_SIZE. */
#define PUPA_KERNEL_MACHINE_KERNEL_IMAGE_SIZE 0xc
#endif /* ! KERNEL_MACHINE_HEADER */

View file

@ -0,0 +1,29 @@
/*
* PUPA -- Preliminary Universal Programming Architecture for GRUB
* Copyright (C) 2002 Yoshinori K. Okuji <okuji@enbug.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef PUPA_LOADER_MACHINE_HEADER
#define PUPA_LOADER_MACHINE_HEADER 1
#include <pupa/types.h>
#include <pupa/symbol.h>
/* This is an asm part of the chainloader. */
void EXPORT_FUNC(pupa_chainloader_real_boot) (int drive, void *part_addr) __attribute__ ((noreturn));
#endif /* ! PUPA_LOADER_MACHINE_HEADER */

View file

@ -0,0 +1,67 @@
/* memory.h - describe the memory map */
/*
* PUPA -- Preliminary Universal Programming Architecture for GRUB
* Copyright (C) 2002 Yoshinori K. Okuji <okuji@enbug.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef PUPA_MEMORY_MACHINE_HEADER
#define PUPA_MEMORY_MACHINE_HEADER 1
/* The scratch buffer used in real mode code. */
#define PUPA_MEMORY_MACHINE_SCRATCH_ADDR 0x68000
#define PUPA_MEMORY_MACHINE_SCRATCH_SEG (PUPA_MEMORY_MACHINE_SCRATCH_ADDR >> 4)
#define PUPA_MEMORY_MACHINE_SCRATCH_SIZE 0x10000
/* The real mode stack. */
#define PUPA_MEMORY_MACHINE_REAL_STACK (0x2000 - 0x10)
/* The size of the protect mode stack. */
#define PUPA_MEMORY_MACHINE_PROT_STACK_SIZE 0x8000
/* The protected mode stack. */
#define PUPA_MEMORY_MACHINE_PROT_STACK \
(PUPA_MEMORY_MACHINE_SCRATCH_ADDR + PUPA_MEMORY_MACHINE_SCRATCH_SIZE \
+ PUPA_MEMORY_MACHINE_PROT_STACK_SIZE - 0x10)
/* The memory area where PUPA uses its own purpose. */
#define PUPA_MEMORY_MACHINE_RESERVED_START \
PUPA_MEMORY_MACHINE_SCRATCH_ADDR
#define PUPA_MEMORY_MACHINE_RESERVED_END \
(PUPA_MEMORY_MACHINE_PROT_STACK + 0x10)
/* The address of a partition table passed to another boot loader. */
#define PUPA_MEMORY_MACHINE_PART_TABLE_ADDR 0x7be
/* The address where another boot loader is loaded. */
#define PUPA_MEMORY_MACHINE_BOOT_LOADER_ADDR 0x7c00
/* The flag for protected mode. */
#define PUPA_MEMORY_MACHINE_CR0_PE_ON 0x1
/* The code segment of the protected mode. */
#define PUPA_MEMORY_MACHINE_PROT_MODE_CSEG 0x8
/* The data segment of the protected mode. */
#define PUPA_MEMORY_MACHINE_PROT_MODE_DSEG 0x10
/* The code segment of the pseudo real mode. */
#define PUPA_MEMORY_MACHINE_PSEUDO_REAL_CSEG 0x18
/* The data segment of the pseudo real mode. */
#define PUPA_MEMORY_MACHINE_PSEUDO_REAL_DSEG 0x20
#endif /* ! PUPA_MEMORY_MACHINE_HEADER */

View file

@ -0,0 +1,243 @@
/*
* PUPA -- Preliminary Universal Programming Architecture for GRUB
* Copyright (C) 1999,2000,2001 Free Software Foundation, Inc.
* Copyright (C) 2002 Yoshinori K. Okuji <okuji@enbug.org>
*
* PUPA is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PUPA; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef PUPA_PARTITION_HEADER
#define PUPA_PARTITION_HEADER 1
#include <pupa/symbol.h>
#include <pupa/types.h>
#include <pupa/err.h>
/* The signature. */
#define PUPA_PARTITION_SIGNATURE 0xaa55
/* This is not a flag actually, but used as if it were a flag. */
#define PUPA_PARTITION_TYPE_HIDDEN_FLAG 0x10
/* DOS partition types. */
#define PUPA_PARTITION_TYPE_NONE 0
#define PUPA_PARTITION_TYPE_FAT12 1
#define PUPA_PARTITION_TYPE_FAT16_LT32M 4
#define PUPA_PARTITION_TYPE_EXTENDED 5
#define PUPA_PARTITION_TYPE_FAT16_GT32M 6
#define PUPA_PARTITION_TYPE_FAT32 0xb
#define PUPA_PARTITION_TYPE_FAT32_LBA 0xc
#define PUPA_PARTITION_TYPE_FAT16_LBA 0xe
#define PUPA_PARTITION_TYPE_WIN95_EXTENDED 0xf
#define PUPA_PARTITION_TYPE_EZD 0x55
#define PUPA_PARTITION_TYPE_MINIX 0x80
#define PUPA_PARTITION_TYPE_LINUX_MINIX 0x81
#define PUPA_PARTITION_TYPE_EXT2FS 0x83
#define PUPA_PARTITION_TYPE_LINUX_EXTENDED 0x85
#define PUPA_PARTITION_TYPE_VSTAFS 0x9e
#define PUPA_PARTITION_TYPE_FREEBSD 0xa5
#define PUPA_PARTITION_TYPE_OPENBSD 0xa6
#define PUPA_PARTITION_TYPE_NETBSD 0xa9
#define PUPA_PARTITION_TYPE_LINUX_RAID 0xfd
/* Constants for BSD disk label. */
#define PUPA_PARTITION_BSD_LABEL_SECTOR 1
#define PUPA_PARTITION_BSD_LABEL_MAGIC 0x82564557
#define PUPA_PARTITION_BSD_MAX_ENTRIES 8
/* BSD partition types. */
#define PUPA_PARTITION_BSD_TYPE_UNUSED 0
#define PUPA_PARTITION_BSD_TYPE_SWAP 1
#define PUPA_PARTITION_BSD_TYPE_V6 2
#define PUPA_PARTITION_BSD_TYPE_V7 3
#define PUPA_PARTITION_BSD_TYPE_SYSV 4
#define PUPA_PARTITION_BSD_TYPE_V71K 5
#define PUPA_PARTITION_BSD_TYPE_V8 6
#define PUPA_PARTITION_BSD_TYPE_BSDFFS 7
#define PUPA_PARTITION_BSD_TYPE_MSDOS 8
#define PUPA_PARTITION_BSD_TYPE_BSDLFS 9
#define PUPA_PARTITION_BSD_TYPE_OTHER 10
#define PUPA_PARTITION_BSD_TYPE_HPFS 11
#define PUPA_PARTITION_BSD_TYPE_ISO9660 12
#define PUPA_PARTITION_BSD_TYPE_BOOT 13
/* FreeBSD-specific types. */
#define PUPA_PARTITION_FREEBSD_TYPE_VINUM 14
#define PUPA_PARTITION_FREEBSD_TYPE_RAID 15
#define PUPA_PARTITION_FREEBSD_TYPE_JFS2 21
/* NetBSD-specific types. */
#define PUPA_PARTITION_NETBSD_TYPE_ADOS 14
#define PUPA_PARTITION_NETBSD_TYPE_HFS 15
#define PUPA_PARTITION_NETBSD_TYPE_FILECORE 16
#define PUPA_PARTITION_NETBSD_TYPE_EXT2FS 17
#define PUPA_PARTITION_NETBSD_TYPE_NTFS 18
#define PUPA_PARTITION_NETBSD_TYPE_RAID 19
#define PUPA_PARTITION_NETBSD_TYPE_CCD 20
#define PUPA_PARTITION_NETBSD_TYPE_JFS2 21
#define PUPA_PARTITION_NETBSD_TYPE_APPLEUFS 22
/* OpenBSD-specific types. */
#define PUPA_PARTITION_OPENBSD_TYPE_ADOS 14
#define PUPA_PARTITION_OPENBSD_TYPE_HFS 15
#define PUPA_PARTITION_OPENBSD_TYPE_FILECORE 16
#define PUPA_PARTITION_OPENBSD_TYPE_EXT2FS 17
#define PUPA_PARTITION_OPENBSD_TYPE_NTFS 18
#define PUPA_PARTITION_OPENBSD_TYPE_RAID 19
/* The BSD partition entry. */
struct pupa_partition_bsd_entry
{
pupa_uint32_t size;
pupa_uint32_t offset;
pupa_uint32_t fragment_size;
pupa_uint8_t fs_type;
pupa_uint8_t fs_fragments;
pupa_uint16_t fs_cylinders;
} __attribute__ ((packed));
/* The BSD disk label. Only define members useful for PUPA. */
struct pupa_partition_disk_label
{
pupa_uint32_t magic;
pupa_uint8_t padding[128];
pupa_uint32_t magic2;
pupa_uint16_t checksum;
pupa_uint16_t num_partitions;
pupa_uint32_t boot_size;
pupa_uint32_t superblock_size;
struct pupa_partition_bsd_entry entries[PUPA_PARTITION_BSD_MAX_ENTRIES];
} __attribute__ ((packed));
/* The partition entry. */
struct pupa_partition_entry
{
/* If active, 0x80, otherwise, 0x00. */
pupa_uint8_t flag;
/* The head of the start. */
pupa_uint8_t start_head;
/* (S | ((C >> 2) & 0xC0)) where S is the sector of the start and C
is the cylinder of the start. Note that S is counted from one. */
pupa_uint8_t start_sector;
/* (C & 0xFF) where C is the cylinder of the start. */
pupa_uint8_t start_cylinder;
/* The partition type. */
pupa_uint8_t type;
/* The end versions of start_head, start_sector and start_cylinder,
respectively. */
pupa_uint8_t end_head;
pupa_uint8_t end_sector;
pupa_uint8_t end_cylinder;
/* The start sector. Note that this is counted from zero. */
pupa_uint32_t start;
/* The length in sector units. */
pupa_uint32_t length;
} __attribute__ ((packed));
/* The structure of MBR. */
struct pupa_partition_mbr
{
/* The code area (actually, including BPB). */
pupa_uint8_t code[446];
/* Four partition entries. */
struct pupa_partition_entry entries[4];
/* The signature 0xaa55. */
pupa_uint16_t signature;
} __attribute__ ((packed));
/* Partition description. */
struct pupa_partition
{
/* The start sector. */
unsigned long start;
/* The length in sector units. */
unsigned long len;
/* The offset of the partition table. */
unsigned long offset;
/* The offset of the extended partition. */
unsigned long ext_offset;
/* The index of this partition in the partition table. */
int index;
/* The DOS partition number. */
int dos_part;
/* The BSD partition number (a == 0). */
int bsd_part;
/* The DOS partition type. */
int dos_type;
/* The BSD partition type. */
int bsd_type;
};
typedef struct pupa_partition *pupa_partition_t;
struct pupa_disk;
pupa_partition_t EXPORT_FUNC(pupa_partition_probe) (struct pupa_disk *disk,
const char *str);
pupa_err_t EXPORT_FUNC(pupa_partition_iterate) (struct pupa_disk *disk,
int (*hook) (const pupa_partition_t partition));
char *EXPORT_FUNC(pupa_partition_get_name) (const pupa_partition_t partition);
static inline unsigned long
pupa_partition_get_start (const pupa_partition_t p)
{
return p->start;
}
static inline unsigned long
pupa_partition_get_len (const pupa_partition_t p)
{
return p->len;
}
static inline int
pupa_partition_is_empty (int type)
{
return (type == PUPA_PARTITION_TYPE_NONE);
}
static inline int
pupa_partition_is_extended (int type)
{
return (type == PUPA_PARTITION_TYPE_EXTENDED
|| type == PUPA_PARTITION_TYPE_WIN95_EXTENDED
|| type == PUPA_PARTITION_TYPE_LINUX_EXTENDED);
}
static inline int
pupa_partition_is_bsd (int type)
{
return (type == PUPA_PARTITION_TYPE_FREEBSD
|| type == PUPA_PARTITION_TYPE_OPENBSD
|| type == PUPA_PARTITION_TYPE_NETBSD);
}
#endif /* ! PUPA_PARTITION_HEADER */

32
include/grub/i386/types.h Normal file
View file

@ -0,0 +1,32 @@
/*
* PUPA -- Preliminary Universal Programming Architecture for GRUB
* Copyright (C) 2002 Yoshinori K. Okuji <okuji@enbug.org>
*
* PUPA is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PUPA; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef PUPA_TYPES_CPU_HEADER
#define PUPA_TYPES_CPU_HEADER 1
/* The size of void *. */
#define PUPA_HOST_SIZEOF_VOID_P 4
/* The size of long. */
#define PUPA_HOST_SIZEOF_LONG 4
/* i386 is little-endian. */
#undef PUPA_HOST_WORDS_BIGENDIAN
#endif /* ! PUPA_TYPES_CPU_HEADER */

61
include/grub/kernel.h Normal file
View file

@ -0,0 +1,61 @@
/*
* PUPA -- Preliminary Universal Programming Architecture for GRUB
* Copyright (C) 2002 Yoshinori K. Okuji <okuji@enbug.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef PUPA_KERNEL_HEADER
#define PUPA_KERNEL_HEADER 1
#include <pupa/types.h>
/* The module header. */
struct pupa_module_header
{
/* The offset of object code. */
pupa_off_t offset;
/* The size of object code plus this header. */
pupa_size_t size;
};
/* The start address of the kernel. */
extern pupa_addr_t pupa_start_addr;
/* The end address of the kernel. */
extern pupa_addr_t pupa_end_addr;
/* The total size of modules including their headers. */
extern pupa_size_t pupa_total_module_size;
/* The size of the kernel image. */
extern pupa_size_t pupa_kernel_image_size;
/* The start point of the C code. */
void pupa_main (void);
/* The machine-specific initialization. This must initialize memory. */
void pupa_machine_init (void);
/* Return the end address of the core image. */
pupa_addr_t pupa_get_end_addr (void);
/* Register all the exported symbols. This is automatically generated. */
void pupa_register_exported_symbols (void);
/* Enter normal mode. */
void pupa_enter_normal_mode (void);
#endif /* ! PUPA_KERNEL_HEADER */

37
include/grub/loader.h Normal file
View file

@ -0,0 +1,37 @@
/* loader.h - OS loaders */
/*
* PUPA -- Preliminary Universal Programming Architecture for GRUB
* Copyright (C) 2002 Yoshinori K. Okuji <okuji@enbug.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef PUPA_LOADER_HEADER
#define PUPA_LOADER_HEADER 1
#include <pupa/file.h>
#include <pupa/symbol.h>
#include <pupa/err.h>
#include <pupa/types.h>
void EXPORT_FUNC(pupa_loader_set) (pupa_err_t (*load_module) (int argc,
char *argv[]),
pupa_err_t (*boot) (void),
pupa_err_t (*unload) (void));
pupa_err_t EXPORT_FUNC(pupa_loader_load_module) (int argc, char *argv[]);
pupa_err_t EXPORT_FUNC(pupa_loader_boot) (void);
#endif /* ! PUPA_LOADER_HEADER */

47
include/grub/misc.h Normal file
View file

@ -0,0 +1,47 @@
/* misc.h - prototypes for misc functions */
/*
* PUPA -- Preliminary Universal Programming Architecture for GRUB
* Copyright (C) 2002 Yoshinori K. Okuji <okuji@enbug.org>
*
* PUPA is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PUPA; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef PUPA_MISC_HEADER
#define PUPA_MISC_HEADER 1
#include <stdarg.h>
#include <pupa/types.h>
#include <pupa/symbol.h>
void *EXPORT_FUNC(pupa_memcpy) (void *dest, const void *src, pupa_size_t n);
int EXPORT_FUNC(pupa_memcmp) (const void *s1, const void *s2, pupa_size_t n);
int EXPORT_FUNC(pupa_strcmp) (const char *s1, const char *s2);
char *EXPORT_FUNC(pupa_strchr) (const char *s, int c);
char *EXPORT_FUNC(pupa_strrchr) (const char *s, int c);
int EXPORT_FUNC(pupa_isspace) (int c);
int EXPORT_FUNC(pupa_isprint) (int c);
int EXPORT_FUNC(pupa_isalpha) (int c);
int EXPORT_FUNC(pupa_tolower) (int c);
unsigned long EXPORT_FUNC(pupa_strtoul) (const char *str, char **end, int base);
char *EXPORT_FUNC(pupa_strdup) (const char *s);
void *EXPORT_FUNC(pupa_memset) (void *s, int c, pupa_size_t n);
pupa_size_t EXPORT_FUNC(pupa_strlen) (const char *s);
int EXPORT_FUNC(pupa_printf) (const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
int EXPORT_FUNC(pupa_vprintf) (const char *fmt, va_list args);
int EXPORT_FUNC(pupa_sprintf) (char *str, const char *fmt, ...) __attribute__ ((format (printf, 2, 3)));
int EXPORT_FUNC(pupa_vsprintf) (char *str, const char *fmt, va_list args);
void EXPORT_FUNC(pupa_stop) (void) __attribute__ ((noreturn));
#endif /* ! PUPA_MISC_HEADER */

39
include/grub/mm.h Normal file
View file

@ -0,0 +1,39 @@
/* mm.h - prototypes and declarations for memory manager */
/*
* PUPA -- Preliminary Universal Programming Architecture for GRUB
* Copyright (C) 2002 Yoshinori K. Okuji <okuji@enbug.org>
*
* PUPA is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PUPA; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef PUPA_MM_H
#define PUPA_MM_H 1
#include <pupa/types.h>
#include <pupa/symbol.h>
void pupa_mm_init_region (void *addr, unsigned size);
void *EXPORT_FUNC(pupa_malloc) (unsigned size);
void EXPORT_FUNC(pupa_free) (void *ptr);
void *EXPORT_FUNC(pupa_realloc) (void *ptr, unsigned size);
void *EXPORT_FUNC(pupa_memalign) (unsigned align, unsigned size);
/* For debugging. */
#define MM_DEBUG 1
#if MM_DEBUG
void pupa_mm_dump (unsigned lineno);
#endif
#endif /* ! PUPA_MM_H */

73
include/grub/net.h Normal file
View file

@ -0,0 +1,73 @@
/*
* PUPA -- Preliminary Universal Programming Architecture for GRUB
* Copyright (C) 2002 Yoshinori K. Okuji <okuji@enbug.org>
*
* PUPA is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PUPA; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef PUPA_NET_HEADER
#define PUPA_NET_HEADER 1
#include <pupa/symbol.h>
#include <pupa/err.h>
#include <pupa/types.h>
struct pupa_net;
struct pupa_net_dev
{
/* The device name. */
const char *name;
/* FIXME: Just a template. */
int (*probe) (struct pupa_net *net, const void *addr);
void (*reset) (struct pupa_net *net);
int (*poll) (struct pupa_net *net);
void (*transmit) (struct pupa_net *net, const void *destip,
unsigned srcsock, unsigned destsock, const void *packet);
void (*disable) (struct pupa_net *net);
/* The next net device. */
struct pupa_net_dev *next;
};
typedef struct pupa_net_dev *pupa_net_dev_t;
struct pupa_fs;
struct pupa_net
{
/* The net name. */
const char *name;
/* The underlying disk device. */
pupa_net_dev_t dev;
/* The binding filesystem. */
struct pupa_fs *fs;
/* FIXME: More data would be required, such as an IP address, a mask,
a gateway, etc. */
/* Device-specific data. */
void *data;
};
typedef struct pupa_net *pupa_net_t;
/* FIXME: How to abstract networks? More consideration is necessary. */
/* Note: Networks are very different from disks, because networks must
be initialized before used, and the status is persistent. */
#endif /* ! PUPA_NET_HEADER */

37
include/grub/rescue.h Normal file
View file

@ -0,0 +1,37 @@
/*
* PUPA -- Preliminary Universal Programming Architecture for GRUB
* Copyright (C) 2002 Yoshinori K. Okuji <okuji@enbug.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef PUPA_RESCUE_HEADER
#define PUPA_RESCUE_HEADER 1
#include <pupa/symbol.h>
/* Enter rescue mode. */
void pupa_enter_rescue_mode (void);
/* Register a rescue mode command. */
void EXPORT_FUNC(pupa_rescue_register_command) (const char *name,
void (*func) (int argc,
char *argv[]),
const char *message);
/* Unregister a rescue mode command. */
void EXPORT_FUNC(pupa_rescue_unregister_command) (const char *name);
#endif /* ! PUPA_RESCUE_HEADER */

40
include/grub/symbol.h Normal file
View file

@ -0,0 +1,40 @@
/*
* PUPA -- Preliminary Universal Programming Architecture for GRUB
* Copyright (C) 1999,2000,2001,2002 Free Software Foundation, Inc.
* Copyright (C) 2002 Yoshinori K. Okuji <okuji@enbug.org>
*
* PUPA is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PUPA; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef PUPA_SYMBOL_HEADER
#define PUPA_SYMBOL_HEADER 1
#include <config.h>
/* Add an underscore to a C symbol in assembler code if needed. */
#ifdef HAVE_ASM_USCORE
# define EXT_C(sym) _ ## sym
#else
# define EXT_C(sym) sym
#endif
#define FUNCTION(x) .globl EXT_C(x) ; EXT_C(x):
#define VARIABLE(x) FUNCTION(x)
/* Mark an exported symbol. */
#define EXPORT_FUNC(x) x
#define EXPORT_VAR(x) x
#endif /* ! PUPA_SYMBOL_HEADER */

120
include/grub/term.h Normal file
View file

@ -0,0 +1,120 @@
/*
* PUPA -- Preliminary Universal Programming Architecture for GRUB
* Copyright (C) 2002 Free Software Foundation, Inc.
* Copyright (C) 2002 Yoshinori K. Okuji <okuji@enbug.org>
*
* PUPA is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PUPA; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef PUPA_TERM_HEADER
#define PUPA_TERM_HEADER 1
#include <pupa/symbol.h>
#include <pupa/types.h>
/* These are used to represent the various color states we use. */
typedef enum
{
/* The color used to display all text that does not use the
user defined colors below. */
PUPA_TERM_COLOR_STANDARD,
/* The user defined colors for normal text. */
PUPA_TERM_COLOR_NORMAL,
/* The user defined colors for highlighted text. */
PUPA_TERM_COLOR_HIGHLIGHT
}
pupa_term_color_state;
/* Flags for representing the capabilities of a terminal. */
/* Some notes about the flags:
- These flags are used by higher-level functions but not terminals
themselves.
- If a terminal is dumb, you may assume that only putchar, getkey and
checkkey are called.
- Some fancy features (setcolorstate, setcolor and setcursor) can be set
to NULL. */
/* Set when input characters shouldn't be echoed back. */
#define PUPA_TERM_NO_ECHO (1 << 0)
/* Set when the editing feature should be disabled. */
#define PUPA_TERM_NO_EDIT (1 << 1)
/* Set when the terminal cannot do fancy things. */
#define PUPA_TERM_DUMB (1 << 2)
/* Set when the terminal needs to be initialized. */
#define PUPA_TERM_NEED_INIT (1 << 16)
struct pupa_term
{
/* The terminal name. */
const char *name;
/* Put a character. */
void (*putchar) (int c);
/* Check if any input character is available. */
int (*checkkey) (void);
/* Get a character. */
int (*getkey) (void);
/* Get the cursor position. The return value is ((X << 8) | Y). */
pupa_uint16_t (*getxy) (void);
/* Go to the position (X, Y). */
void (*gotoxy) (pupa_uint8_t x, pupa_uint8_t y);
/* Clear the screen. */
void (*cls) (void);
/* Set the current color to be used */
void (*setcolorstate) (pupa_term_color_state state);
/* Set the normal color and the highlight color. The format of each
color is VGA's. */
void (*setcolor) (pupa_uint8_t normal_color, pupa_uint8_t highlight_color);
/* Turn on/off the cursor. */
void (*setcursor) (int on);
/* The feature flags defined above. */
pupa_uint32_t flags;
/* The next terminal. */
struct pupa_term *next;
};
typedef struct pupa_term *pupa_term_t;
void EXPORT_FUNC(pupa_term_register) (pupa_term_t term);
void EXPORT_FUNC(pupa_term_unregister) (pupa_term_t term);
void EXPORT_FUNC(pupa_term_iterate) (int (*hook) (pupa_term_t term));
void EXPORT_FUNC(pupa_term_set_current) (pupa_term_t term);
pupa_term_t EXPORT_FUNC(pupa_term_get_current) (void);
void EXPORT_FUNC(pupa_putchar) (int c);
int EXPORT_FUNC(pupa_getkey) (void);
int EXPORT_FUNC(pupa_checkkey) (void);
pupa_uint16_t EXPORT_FUNC(pupa_getxy) (void);
void EXPORT_FUNC(pupa_gotoxy) (pupa_uint8_t x, pupa_uint8_t y);
void EXPORT_FUNC(pupa_cls) (void);
void EXPORT_FUNC(pupa_setcolorstate) (pupa_term_color_state state);
void EXPORT_FUNC(pupa_setcolor) (pupa_uint8_t normal_color,
pupa_uint8_t highlight_color);
int EXPORT_FUNC(pupa_setcursor) (int on);
/* For convenience. */
#define PUPA_TERM_ASCII_CHAR(c) ((c) & 0xff)
#endif /* ! PUPA_TERM_HEADER */

141
include/grub/types.h Normal file
View file

@ -0,0 +1,141 @@
/*
* PUPA -- Preliminary Universal Programming Architecture for GRUB
* Copyright (C) 2002 Yoshinori K. Okuji <okuji@enbug.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef PUPA_TYPES_HEADER
#define PUPA_TYPES_HEADER 1
#include <config.h>
#include <pupa/cpu/types.h>
#ifdef PUPA_UTIL
# define PUPA_CPU_SIZEOF_VOID_P SIZEOF_VOID_P
# define PUPA_CPU_SIZEOF_LONG SIZEOF_LONG
# ifdef WORDS_BIGENDIAN
# define PUPA_CPU_WORDS_BIGENDIAN 1
# else
# undef PUPA_CPU_WORDS_BIGENDIAN
# endif
#else /* ! PUPA_UTIL */
# define PUPA_CPU_SIZEOF_VOID_P PUPA_HOST_SIZEOF_VOID_P
# define PUPA_CPU_SIZEOF_LONG PUPA_HOST_SIZEOF_LONG
# ifdef PUPA_HOST_WORDS_BIGENDIAN
# define PUPA_CPU_WORDS_BIGENDIAN 1
# else
# undef PUPA_CPU_WORDS_BIGENDIAN
# endif
#endif /* ! PUPA_UTIL */
#if PUPA_CPU_SIZEOF_VOID_P != PUPA_CPU_SIZEOF_LONG
# error "This architecture is not supported because sizeof(void *) != sizeof(long)"
#endif
#if PUPA_CPU_SIZEOF_VOID_P != 4 && PUPA_CPU_SIZEOF_VOID_P != 8
# error "This architecture is not supported because sizeof(void *) != 4 and sizeof(void *) != 8"
#endif
/* Define various wide integers. */
typedef signed char pupa_int8_t;
typedef short pupa_int16_t;
typedef int pupa_int32_t;
#if PUPA_CPU_SIZEOF_VOID_P == 8
typedef long pupa_int64_t;
#else
typedef long long pupa_int64_t;
#endif
typedef unsigned char pupa_uint8_t;
typedef unsigned short pupa_uint16_t;
typedef unsigned pupa_uint32_t;
#if PUPA_CPU_SIZEOF_VOID_P == 8
typedef unsigned long pupa_uint64_t;
#else
typedef unsigned long long pupa_uint64_t;
#endif
/* Misc types. */
#if PUPA_HOST_SIZE_OF_VOID_P == 8
typedef pupa_uint64_t pupa_addr_t;
typedef pupa_uint64_t pupa_off_t;
typedef pupa_uint64_t pupa_size_t;
typedef pupa_int64_t pupa_ssize_t;
#else
typedef pupa_uint32_t pupa_addr_t;
typedef pupa_uint32_t pupa_off_t;
typedef pupa_uint32_t pupa_size_t;
typedef pupa_int32_t pupa_ssize_t;
#endif
/* Byte-orders. */
#define pupa_swap_bytes16(x) \
({ \
pupa_uint16_t _x = (x); \
(_x << 8) | (_x >> 8); \
})
#define pupa_swap_bytes32(x) \
({ \
pupa_uint32_t _x = (x); \
(pupa_uint32_t) ((_x << 24) \
| ((_x & (pupa_uint32_t) 0xFF00UL) << 8) \
| ((_x & (pupa_uint32_t) 0xFF0000UL) >> 8) \
| (_x >> 24)); \
})
#define pupa_swap_bytes64(x) \
({ \
pupa_uint64_t _x = (x); \
(pupa_uint64_t) ((_x << 56) \
| ((_x & (pupa_uint64_t) 0xFF00ULL) << 40) \
| ((_x & (pupa_uint64_t) 0xFF0000ULL) << 24) \
| ((_x & (pupa_uint64_t) 0xFF000000ULL) << 8) \
| ((_x & (pupa_uint64_t) 0xFF00000000ULL) >> 8) \
| ((_x & (pupa_uint64_t) 0xFF0000000000ULL) >> 24) \
| ((_x & (pupa_uint64_t) 0xFF000000000000ULL) >> 40) \
| (_x >> 56)); \
})
#ifdef PUPA_CPU_WORDS_BIGENDIAN
# define pupa_cpu_to_le16(x) pupa_swap_bytes16(x)
# define pupa_cpu_to_le32(x) pupa_swap_bytes32(x)
# define pupa_cpu_to_le64(x) pupa_swap_bytes64(x)
# define pupa_le_to_cpu16(x) pupa_swap_bytes16(x)
# define pupa_le_to_cpu32(x) pupa_swap_bytes32(x)
# define pupa_le_to_cpu64(x) pupa_swap_bytes64(x)
# define pupa_cpu_to_be16(x) ((pupa_uint16_t) (x))
# define pupa_cpu_to_be32(x) ((pupa_uint32_t) (x))
# define pupa_cpu_to_be64(x) ((pupa_uint64_t) (x))
# define pupa_be_to_cpu16(x) ((pupa_uint16_t) (x))
# define pupa_be_to_cpu32(x) ((pupa_uint32_t) (x))
# define pupa_be_to_cpu64(x) ((pupa_uint64_t) (x))
#else /* ! WORDS_BIGENDIAN */
# define pupa_cpu_to_le16(x) ((pupa_uint16_t) (x))
# define pupa_cpu_to_le32(x) ((pupa_uint32_t) (x))
# define pupa_cpu_to_le64(x) ((pupa_uint64_t) (x))
# define pupa_le_to_cpu16(x) ((pupa_uint16_t) (x))
# define pupa_le_to_cpu32(x) ((pupa_uint32_t) (x))
# define pupa_le_to_cpu64(x) ((pupa_uint64_t) (x))
# define pupa_cpu_to_be16(x) pupa_swap_bytes16(x)
# define pupa_cpu_to_be32(x) pupa_swap_bytes32(x)
# define pupa_cpu_to_be64(x) pupa_swap_bytes64(x)
# define pupa_be_to_cpu16(x) pupa_swap_bytes16(x)
# define pupa_be_to_cpu32(x) pupa_swap_bytes32(x)
# define pupa_be_to_cpu64(x) pupa_swap_bytes64(x)
#endif /* ! WORDS_BIGENDIAN */
#endif /* ! PUPA_TYPES_HEADER */

40
include/grub/util/misc.h Normal file
View file

@ -0,0 +1,40 @@
/*
* PUPA -- Preliminary Universal Programming Architecture for GRUB
* Copyright (C) 2002 Yoshinori K. Okuji <okuji@enbug.org>
*
* PUPA is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PUPA; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef PUPA_UTIL_MISC_HEADER
#define PUPA_UTIL_MISC_HEADER 1
#include <stdlib.h>
#include <stdio.h>
extern char *progname;
extern int verbosity;
void pupa_util_info (const char *fmt, ...);
void pupa_util_error (const char *fmt, ...) __attribute__ ((noreturn));
void *xmalloc (size_t size);
char *xstrdup (const char *str);
char *pupa_util_get_path (const char *dir, const char *file);
size_t pupa_util_get_image_size (const char *path);
char *pupa_util_read_image (const char *path);
void pupa_util_write_image (const char *img, size_t size, FILE *out);
#endif /* ! PUPA_UTIL_MISC_HEADER */

View file

@ -0,0 +1,36 @@
/*
* PUPA -- Preliminary Universal Programming Architecture for GRUB
* Copyright (C) 2002 Yoshinori K. Okuji <okuji@enbug.org>
*
* PUPA is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PUPA; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef PUPA_UTIL_RESOLVE_HEADER
#define PUPA_UTIL_RESOLVE_HEADER 1
struct pupa_util_path_list
{
const char *name;
struct pupa_util_path_list *next;
};
/* Resolve the dependencies of the modules MODULES using the information
in the file DEP_LIST_FILE. The directory PREFIX is used to find files. */
struct pupa_util_path_list *
pupa_util_resolve_dependencies (const char *prefix,
const char *dep_list_file,
char *modules[]);
#endif /* ! PUPA_UTIL_RESOLVE_HEADER */