[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: stage1_5, How does it work? Plus New Filesystem
From: |
Shaun Savage |
Subject: |
Re: stage1_5, How does it work? Plus New Filesystem |
Date: |
Fri, 19 Jan 2001 11:18:28 +0100 |
OKUJI Yoshinori wrote:
>
> Shaun, please post your messages to bug-grub.
>
>
> > Compressed Block Device is a linux kernel driver that does demand
> > decompression of the filesystem. It is not a file system to speak of,
> > it is a block device BUT the partition "image" can have the kernel in
> > it, the stage2 bootloader, the menu.lst, splash screen, ..... It does
> > it own partition managment. this partition has a pseudo file system on
> > it where the content are files.
> >
> > The CBD is designed for use in embedded devices. It shrinks the
> > filesystem size by 2.5 - 3 times so less storage is needed.
> > For more information see http://www.infomatec.com/cbd
>
>
> This explains how GRUB works *usually*, but GRUB is not restricted to
> the usage. Strictly speaking, you can put Stage 1.5 (or Stage 2)
> anywhere you like, and Stage 2 can load a configuration file from
> anywhere on your disks (The configuration file needs not to be put in
> a filesystem). See the Programmer Reference Manual in the GRUB manual,
> for more details.
>
> > I have attached the CBD files htat I am using. I also 'hacked' the
> > configure.in and Makefile.in and Makefile.am BUT I am not sure I did the
> > right things. It works, but it makes the stage2/makefile every time.
>
> You shouldn't modify Makefile.in manually; It's a automatically
> generated file with Automake. Anyway, send a patch to the list, and we
> will suggest a better way or approve the patch.
>
Could I get some help with the configuration? I can enclose the source
files
for the CBD.
Shaun
/*
* This header file defines the ioctls
* for the CBD DRIVER
* we use 'i' as "our letter" (c.f. linux/Documentation/ioctl-number.txt)
*/
#ifndef _CBD_H_
#define _CBD_H_
#define CBD_MAJOR 61
#define CBD_LETTER 'i'
#define CBD_ERASE_SECTION _IOWR(CBD_LETTER, 1, long *)
#define CBD_INVAL_BUFFERS _IOWR(CBD_LETTER, 2, long *)
#define CBD_INVAL_PARTITION _IOWR(CBD_LETTER, 3, long *)
#define CBD_GET_FREE_SECTION _IOWR(CBD_LETTER, 4, long *)
#define CBD_GET_PARTITION_VERSION _IOWR(CBD_LETTER, 5, long *)
#define CBD_COMMIT_SECTION _IOWR(CBD_LETTER, 6, long *)
#define CBD_GET_SIZE _IOWR(CBD_LETTER, 7, long *)
#define CBD_GET_HWCONFIG _IOWR(CBD_LETTER, 8, long *)
#define CBD_GET_RAWDEVICE _IOWR(CBD_LETTER, 9, long *)
#define CBD_NEW_FORMAT _IOWR(CBD_LETTER, 10, long *)
/*
* Section Header:
*
* Each section (except BIOS-sections and unintialized sections)
* starts with a section header:
*/
#define CBD_SECTION_SIZE 0x10000L /* 64 K */
#define IGF_SECT_HDR_LEN 32 /* we assume section hdrs to be that long! */
#define IGF_SECT_DATA_LEN (CBD_SECTION_SIZE - IGF_SECT_HDR_LEN)
#define CBD_DEV_0_NAME "/dev/igf0"
#define CBD_MAGIC 0x4c454749
#define CBD_PARTHDR_CRC_START (2 * sizeof (ulong))
#define DRIVER_VERSION -1
#define CBD_MAX_MINORS 16
/* typedef unsigned long ulong; */
/* typedef unsigned short unsigned short; */
#ifndef uchar
typedef unsigned char uchar;
#endif
/* content types */
/* NONE nothing */
#define NONE 0x454E4F4E
/* CLST cluster map */
#define CLST 0x54534C43
/* SECT section map */
#define SECT 0x54434553
/* KRNL kernel */
#define KRNL 0x4C4E524B
/* BOOT boot */
#define BOOT 0x544F4F42
/* BOT1 boot1 */
#define BOT1 0x31544F42
/* BOT2 boot2 */
#define BOT2 0x32544F42
/* BOT3 boot3 */
#define BOT3 0x33544F42
/* SPLS splash */
#define SPLS 0x534C5053
/* INRD initrd */
#define INRD 0x44544E49
/* DICT dictionary */
#define DICT 0x54434944
/* MKEY make public key */
#define MKEY 0x59454B4D
/* OKEY oem public key */
#define OKEY 0x59454B4F
/* RKEY register public key */
#define RKEY 0x59454B52
/* SIGN signature */
#define SIGN 0x4E474953
typedef struct cbd_part_content {
char name[4];
unsigned int offset;
unsigned int length;
unsigned int crc;
} cbd_part_content_t; /* struct cbd_part_content */
typedef struct cbd_part_hdr {
unsigned int magic; /* 0 IGEL */
unsigned int hdr_crc; /* 4 checksum */
char drvver; /* 8 driver version */
uchar cluster_shift; /* 9 cluster size 32k */
uchar n_content; /* A number of types */
uchar cbd_minor; /* B minor nimber */
unsigned short hdr_len; /* C length */
unsigned short n_sections; /* E number of sections
*/
unsigned int version; /* 10 partition version
*/
unsigned int update_count; /* 14 sequence */
unsigned int n_clusters; /* 18 number of cluster
*/
unsigned int offset_section_table; /* 1C start of section
table */
cbd_part_content_t content_table[0]; /* 20 content table */
} cbd_part_hdr_t; /* struct cbd_part_hdr */
/* now comes section table */
/* then comes contents */
#define align(a,b) (((a + b -1)/b) * b)
/* proc data information */
/* size: total free */
#define CBD_PROC_SIZE "%d %d"
/* map: array of status and partition */
/* part: lines of
"part# version update# cluster# section# mounted*/
#define CBD_PROC_PART "%d %x %x %x %x %d"
/* info: ??? */
/* device: lines of block devices */
#endif
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 1996 Erich Boleyn <address@hidden>
* Copyright (C) 2000 Free Software Foundation, Inc.
*
* 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.
*/
/*
* Elements of this file were originally from the FreeBSD "biosboot"
* bootloader file "disk.c" dated 4/12/95.
*
* The license and header comments from that file are included here.
*/
/*
* Mach Operating System
* Copyright (c) 1992, 1991 Carnegie Mellon University
* All Rights Reserved.
*
* Permission to use, copy, modify and distribute this software and its
* documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or address@hidden
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie Mellon
* the rights to redistribute these changes.
*
* from: Mach, Revision 2.2 92/04/04 11:35:49 rpd
* $Id: fsys_ffs.c,v 1.8 2000/04/15 13:39:38 okuji Exp $
*/
#ifdef FSYS_CBD
#include "shared.h"
#include "filesys.h"
#include "defs.h"
#include "dir.h"
#include "fs.h"
#include "cbd.h"
typedef struct part_s {
unsigned int start;
unsigned int hdr_len;
unsigned int n_sections;
unsigned long version, update_count;
} part_t;
/* used for filesystem map blocks */
static unsigned short section_map[2048];
static part_t part_map[15];
static int n_parts;
static int version, update_count;
static cbd_part_content_t *content;
/* pointer to superblock */
#define SUPERBLOCK ((struct fs *) ( FSYS_BUF + 8192 ))
#define INODE ((struct icommon *) ( FSYS_BUF + 16384 ))
#define MAPBUF ( FSYS_BUF + 24576 )
#define MAPBUF_LEN 8192
static int data_read(cbd_part_content_t *cont, unsigned long foffset, char*
buf,int len)
{
int rslt;
part_t *ppart = &part_map[0];
unsigned long sector,offset,section;
int orcnt, tioncnt;
section = ppart->start;
offset = foffset + cont->offset;
sector = (section<<7) + (offset >> 9);
offset = offset & 0x01ff;
orcnt = (len + 511)>> 9;
tioncnt = (orcnt + 127 )>>7;
rslt = devread(sector,offset,len, buf);
if(rslt <1)
return 0;
// memcpy(buf,FSYS_BUF,len);
filepos += len;
return len;
}
int
cbd_mount (void)
{
unsigned long start_sector;
unsigned int section=0, part_size;
cbd_part_hdr_t hdr;
part_t *ppart;
start_sector=0;
n_parts=0;
part_size = part_length>>7;
content = NULL;
if(part_size > 1024)
return 0;
for(section=1;section < part_size;section++) {
section_map[section] = 0;
}
for(section=1;(!start_sector) && (section < part_size); section++) {
if(section_map[section])
continue; /* used already */
devread(section<<7,0,0x20,(char*)&hdr);
if(hdr.magic != CBD_MAGIC)
continue;
/* found something */
if(hdr.drvver > -1)
continue; /* first check */
ppart = &part_map[n_parts];
section_map[section] = n_parts++;
ppart->start = section;
ppart->n_sections = hdr.n_sections;
ppart->version = version = hdr.version;
ppart->hdr_len = hdr.hdr_len;
ppart->update_count = update_count = hdr.update_count;
if(hdr.cbd_minor != 1)
continue;
start_sector = section<<7;
}
if(!start_sector)
return 0;
return 1;
}
int
cbd_read (char *buf, int len)
{
if((content == NULL) || (filemax == 0))
return 0;
if(len==0)
return 1;
return data_read(content, filepos, buf, len);
}
int
cbd_dir (char *dirname)
{
int i;
part_t *ppart = &part_map[0];
cbd_part_hdr_t *hdr = (cbd_part_hdr_t*)FSYS_BUF;
unsigned short *section_tbl;
filemax = 0;
devread(ppart->start<<7,0,ppart->hdr_len,(char*)FSYS_BUF);
for(i=0 ; i< hdr->hdr_len ; i++) {
if((*(int*)hdr->content_table[i].name) == *(int*)&dirname[1] ) {
content = &hdr->content_table[i];
filepos = 0;
filemax = content->length;
section_tbl = (unsigned short*) ((char*)hdr +
hdr->offset_section_table);
for( i=0 ; i < hdr->n_sections ; i++) {
section_map[i] = section_tbl[i];
}
return 1;
}
}
return 0;
}
void
cbd_close(void)
{
}
int
cbd_embed (int *start_sector, int needed_sectors)
{
unsigned int section=0;
cbd_part_hdr_t hdr;
part_t *ppart;
start_sector=0;
n_parts=0;
for(section=1;;section++) {
section_map[section] = 0;
}
for(section=1;!start_sector; section++) {
if(section_map)
continue; /* used already */
devread(section<<7,0,0x20,(char*)&hdr);
if(hdr.magic != CBD_MAGIC)
continue;
/* found something */
if(hdr.drvver > -1)
continue; /* first check */
ppart = &part_map[n_parts];
section_map[section] = n_parts++;
ppart->start = section;
ppart->n_sections = hdr.n_sections;
ppart->version = version = hdr.version;
ppart->update_count = update_count = hdr.update_count;
if(hdr.cbd_minor != 1)
continue;
*start_sector = section<<7;
}
return 1;
}
#endif /* FSYS_CBD */