more nits, get hings to work.
This commit is contained in:
parent
8b73dcc250
commit
a99e7f00c7
12 changed files with 176 additions and 18 deletions
137
src/include/pc80/ide.h
Normal file
137
src/include/pc80/ide.h
Normal file
|
|
@ -0,0 +1,137 @@
|
|||
/*
|
||||
* UBL, The Universal Talkware Boot Loader
|
||||
* Copyright (C) 2000 Universal Talkware 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Note: Parts of this code grew out of the Openbios effort that was
|
||||
* abandoned. Without the info that we were able to learn from
|
||||
* OpenBios this program would have never worked. We are forever
|
||||
* grateful for those who came before us.
|
||||
*
|
||||
* This code can be retrieved in a machine/human readable form at:
|
||||
*
|
||||
* http://www.talkware.net/GPL/UBL
|
||||
*
|
||||
* Anyone making changes to this code please send them to us so we
|
||||
* can include them in the standard release.
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
#if !defined(IDE_H_INCLUDE)
|
||||
#define IDE_H_INCLUDE
|
||||
|
||||
#include <types.h>
|
||||
|
||||
typedef struct {
|
||||
unsigned short controller_port;
|
||||
unsigned short num_heads;
|
||||
unsigned short num_cylinders;
|
||||
unsigned short num_sectors_per_track;
|
||||
unsigned long num_sectors; /* total */
|
||||
unsigned char address_mode; /* am i lba (0x40) or chs (0x00) */
|
||||
unsigned char model_number[40];
|
||||
unsigned char drive_exists;
|
||||
} harddisk_info_t;
|
||||
|
||||
#define NUM_HD (2)
|
||||
|
||||
extern harddisk_info_t harddisk_info[NUM_HD];
|
||||
|
||||
extern int ide_init(void);
|
||||
extern int ide_read_sector(int driveno, void * buf, unsigned int sector,
|
||||
int byte_offset, int n_bytes);
|
||||
extern int ide_read_data(unsigned base, void * buf, size_t size);
|
||||
extern int ide_write_data(unsigned base, void * buf, size_t size);
|
||||
extern int ide_shutdown(void);
|
||||
|
||||
|
||||
|
||||
#if 1
|
||||
#define PORT80(x) (outb_p(x, 0x80))
|
||||
#else
|
||||
#define PORT80(x) (0)
|
||||
#endif
|
||||
|
||||
#define IDE_SECTOR_SIZE 0x200
|
||||
|
||||
#define IDE_BASE1 (0x1F0u) /* primary controller */
|
||||
#define IDE_BASE2 (0x170u) /* secondary */
|
||||
#define IDE_BASE3 (0x0F0u) /* third */
|
||||
#define IDE_BASE4 (0x070u) /* fourth */
|
||||
|
||||
#define IDE_REG_EXTENDED_OFFSET (0x200u)
|
||||
|
||||
#define IDE_REG_DATA(base) ((base) + 0u) /* word register */
|
||||
#define IDE_REG_ERROR(base) ((base) + 1u)
|
||||
#define IDE_REG_PRECOMP(base) ((base) + 1u)
|
||||
#define IDE_REG_SECTOR_COUNT(base) ((base) + 2u)
|
||||
#define IDE_REG_SECTOR_NUMBER(base) ((base) + 3u)
|
||||
#define IDE_REG_CYLINDER_LSB(base) ((base) + 4u)
|
||||
#define IDE_REG_CYLINDER_MSB(base) ((base) + 5u)
|
||||
#define IDE_REG_DRIVEHEAD(base) ((base) + 6u)
|
||||
#define IDE_REG_STATUS(base) ((base) + 7u)
|
||||
#define IDE_REG_COMMAND(base) ((base) + 7u)
|
||||
#define IDE_REG_ALTSTATUS(base) ((base) + IDE_REG_EXTENDED_OFFSET + 6u)
|
||||
#define IDE_REG_CONTROL(base) ((base) + IDE_REG_EXTENDED_OFFSET + 6u)
|
||||
#define IDE_REG_ADDRESS(base) ((base) + IDE_REG_EXTENDED_OFFSET + 7u)
|
||||
|
||||
typedef struct {
|
||||
unsigned char precomp;
|
||||
unsigned char sector_count;
|
||||
unsigned char sector_number;
|
||||
unsigned short cylinder;
|
||||
unsigned char drivehead;
|
||||
# define IDE_DH_DEFAULT (0xA0)
|
||||
# define IDE_DH_HEAD(x) ((x) & 0x0F)
|
||||
# define IDE_DH_MASTER (0x00)
|
||||
# define IDE_DH_SLAVE (0x10)
|
||||
# define IDE_DH_DRIVE(x) ((((x) & 1) != 0)?IDE_DH_SLAVE:IDE_DH_MASTER)
|
||||
# define IDE_DH_LBA (0x40)
|
||||
# define IDE_DH_CHS (0x00)
|
||||
|
||||
} ide_cmd_param_t;
|
||||
|
||||
#define IDE_DEFAULT_COMMAND { 0xFFu, 0x01, 0x00, 0x0000, IDE_DH_DEFAULT }
|
||||
|
||||
typedef enum {
|
||||
IDE_CMD_NOOP = 0,
|
||||
IDE_CMD_RECALIBRATE = 0x10,
|
||||
IDE_CMD_READ_MULTI_RETRY = 0x20,
|
||||
IDE_CMD_READ_MULTI = IDE_CMD_READ_MULTI_RETRY,
|
||||
IDE_CMD_READ_MULTI_NORETRY = 0x21,
|
||||
|
||||
IDE_CMD_DRIVE_DIAG = 0x90,
|
||||
IDE_CMD_SET_PARAMS = 0x91,
|
||||
IDE_CMD_STANDBY_IMMEDIATE = 0x94, /* 2 byte command- also send
|
||||
IDE_CMD_STANDBY_IMMEDIATE2 */
|
||||
IDE_CMD_SET_MULTIMODE = 0xC6,
|
||||
IDE_CMD_STANDBY_IMMEDIATE2 = 0xE0,
|
||||
IDE_CMD_GET_INFO = 0xEC
|
||||
} ide_command_t;
|
||||
|
||||
|
||||
#endif /* IDE_H_INCLUDE */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
object linuxbiosmain.o
|
||||
object linuxpci.o
|
||||
object newpci.o
|
||||
object clog2.o
|
||||
object printk.o
|
||||
object serial_subr.o SERIAL_CONSOLE
|
||||
object video_subr.o VIDEO_CONSOLE
|
||||
|
|
@ -19,4 +20,4 @@ object fallback_boot.o HAVE_FALLBACK_BOOT
|
|||
object compute_ip_checksum.o
|
||||
object version.o
|
||||
# Force version.o to recompile every time
|
||||
makedefine .PHONY : version.o
|
||||
makedefine .PHONY : version.o
|
||||
|
|
|
|||
18
src/lib/clog2.c
Normal file
18
src/lib/clog2.c
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
#include <printk.h>
|
||||
|
||||
static inline unsigned long log2(unsigned long x)
|
||||
{
|
||||
// assume 8 bits per byte.
|
||||
unsigned long i = 1 << (sizeof(x)*8 - 1);
|
||||
unsigned long pow = sizeof(x) * 8 - 1;
|
||||
|
||||
if (! x) {
|
||||
printk_emerg(__FUNCTION__
|
||||
" called with invalid parameter of 0\n");
|
||||
return -1;
|
||||
}
|
||||
for(; i > x; i >>= 1, pow--)
|
||||
;
|
||||
|
||||
return pow;
|
||||
}
|
||||
|
|
@ -1097,9 +1097,9 @@ int gunzip(void)
|
|||
return -1;
|
||||
}
|
||||
(ulg)get_byte(); /* Get timestamp */
|
||||
((ulg)get_byte()) << 8;
|
||||
((ulg)get_byte()) << 16;
|
||||
((ulg)get_byte()) << 24;
|
||||
((ulg)get_byte());// << 8;
|
||||
((ulg)get_byte());// << 16;
|
||||
((ulg)get_byte());// << 24;
|
||||
|
||||
(void)get_byte(); /* Ignore extra flags for the moment */
|
||||
(void)get_byte(); /* Ignore OS type for the moment */
|
||||
|
|
|
|||
|
|
@ -23,7 +23,8 @@ static char rcsid[] = "$Id$";
|
|||
#include <string.h>
|
||||
#include <subr.h>
|
||||
|
||||
|
||||
// yes we could do Yet Another Include File, but ...
|
||||
int sprintf(char * buf, const char *fmt, ...);
|
||||
|
||||
/**
|
||||
* This is the root of the PCI tree. A PCI tree always has
|
||||
|
|
@ -317,7 +318,7 @@ static void pci_bus_read_resources(struct pci_dev *dev)
|
|||
static void pci_set_resource(struct pci_dev *dev, struct resource *resource)
|
||||
{
|
||||
unsigned long base, limit;
|
||||
unsigned long bridge_align;
|
||||
unsigned long bridge_align = MEM_BRIDGE_ALIGN; // stupid warnings.
|
||||
unsigned char buf[10];
|
||||
|
||||
/* Make certain the resource has actually been set */
|
||||
|
|
@ -447,11 +448,13 @@ static void pci_dev_set_resources(struct pci_dev *dev)
|
|||
}
|
||||
|
||||
|
||||
|
||||
// probably dead.
|
||||
#if 0
|
||||
static void pci_noop(struct pci_dev *dev)
|
||||
{
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
struct pci_dev_operations default_pci_ops_dev = {
|
||||
.read_resources = pci_dev_read_resources,
|
||||
.set_resources = pci_dev_set_resources,
|
||||
|
|
|
|||
|
|
@ -540,7 +540,7 @@ void compute_allocate_resource(
|
|||
resource = 0;
|
||||
|
||||
/* Walk through all the devices on the current bus and compute the addresses */
|
||||
while(dev = largest_resource(bus, &resource, type_mask, type)) {
|
||||
while((dev = largest_resource(bus, &resource, type_mask, type))) {
|
||||
unsigned long size;
|
||||
/* Do NOT I repeat do not ignore resources which have zero size.
|
||||
* If they need to be ignored dev->read_resources should not even
|
||||
|
|
@ -879,13 +879,13 @@ void pci_initialize(void)
|
|||
void
|
||||
handle_superio(int pass, struct superio *all_superio[], int nsuperio)
|
||||
{
|
||||
int i;
|
||||
struct superio *s;
|
||||
int i = 0;
|
||||
struct superio *s = all_superio[0];
|
||||
|
||||
printk_debug("handle_superio start, s %p nsuperio %d s->super %p\n",
|
||||
s, nsuperio, s->super);
|
||||
|
||||
for (i = 0; i < nsuperio; i++){
|
||||
for (; i < nsuperio; i++){
|
||||
s = all_superio[i];
|
||||
printk_debug(__FUNCTION__
|
||||
" Pass %d, check #%d, s %p s->super %p\n",
|
||||
|
|
|
|||
|
|
@ -18,6 +18,6 @@ struct mem_range *sizeram(void)
|
|||
mem[1].sizek = size - mem[1].basek;
|
||||
mem[2].basek = 0;
|
||||
mem[2].sizek = 0;
|
||||
return &mem;
|
||||
return mem;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,4 +27,4 @@ set_memory_size:
|
|||
|
||||
set_memory_size_end:
|
||||
RETSP
|
||||
set_memory_size_out:
|
||||
set_memory_size_out:
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@
|
|||
#include <arch/io.h>
|
||||
#include <printk.h>
|
||||
#include <string.h>
|
||||
#include "ide.h"
|
||||
#include <pc80/ide.h>
|
||||
|
||||
static __inline__ int wait_for_notbusy(unsigned base)
|
||||
{
|
||||
|
|
@ -330,7 +330,7 @@ int ide_read_sector(int drive, void * buffer, unsigned int block, int byte_offse
|
|||
unsigned int track;
|
||||
int status;
|
||||
int address_mode = harddisk_info[drive].address_mode;
|
||||
int i;
|
||||
//int i;
|
||||
|
||||
//printk_debug(__FUNCTION__ " drive[%d], buffer[%08x], block[%08x], offset[%d], n_bytes[%d]\n",
|
||||
// drive, buffer, block, byte_offset, n_bytes);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#include <pci.h>
|
||||
#include <pci_ids.h>
|
||||
#include <southbridge/amd/amd766.h>
|
||||
#include <ide.h>
|
||||
#include <pc80/ide.h>
|
||||
|
||||
void amd766_enable_ide(int enable_a, int enable_b)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ void nvram_on(void)
|
|||
dev = pci_find_device(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_VIPER_7410, 0);
|
||||
if (dev != NULL) {
|
||||
u8 segen;
|
||||
u32 regval;
|
||||
pci_read_config_byte(dev, 0x43, &segen);
|
||||
/* Enable 4MB rom access at 0xFFC00000 - 0xFFFFFFFF */
|
||||
segen |= 0x80;
|
||||
|
|
|
|||
|
|
@ -179,4 +179,4 @@ smbus_read_byte:
|
|||
|
||||
smbus_code_end:
|
||||
CALL_LABEL(enable_smbus)
|
||||
CALL_LABEL(setup_smbus)
|
||||
CALL_LABEL(setup_smbus)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue