[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[MiNT] [PATCH] Add PCI-BIOS functions to kentry structure
Alan, here is the patch for adding PCI-BIOS functions to kentry.
Please check and commit if it's fine for you. Thanks!
Index: sys/kentry.c
===================================================================
RCS file: /mint/freemint/sys/kentry.c,v
retrieving revision 1.20
diff -u -8 -r1.20 kentry.c
--- sys/kentry.c 26 Mar 2014 10:16:36 -0000 1.20
+++ sys/kentry.c 26 Mar 2014 15:18:56 -0000
@@ -46,16 +46,17 @@
# include "global.h" /* global */
# include "ipc_socketutil.h" /* so_* */
# include "k_exec.h" /* create_process */
# include "k_kthread.h" /* kthread_create, kthread_exit */
# include "k_prot.h" /* proc_setuid/proc_setgid */
# include "kmemory.h" /* kmalloc, kfree */
# include "memory.h" /* addr2mem, attach_region, detach_region */
# include "module.h" /* load_modules */
+# include "pcibios.h"
# include "proc.h" /* sleep, wake, wakeselect, iwake */
# include "proc_help.h" /* proc_extensions */
# include "proc_wakeup.h" /* addprocwakeup */
# include "semaphores.h" /* semaphore_* */
# include "signal.h" /* ikill */
# include "syscall_vectors.h" /* bios_tab, dos_tab */
# include "time.h" /* xtime */
# include "timeout.h" /* nap, addtimeout, canceltimeout, addroottimeout, cancelroottimeout */
Index: sys/pcibios.h
===================================================================
RCS file: /mint/freemint/sys/pcibios.h,v
retrieving revision 1.2
diff -u -8 -r1.2 pcibios.h
--- sys/pcibios.h 23 Mar 2014 00:21:18 -0000 1.2
+++ sys/pcibios.h 26 Mar 2014 15:18:56 -0000
@@ -51,17 +51,17 @@
long _cdecl sys_pcibios (ushort op,
long a1, long a2, long a3, long a4,
long a5, long a6, long a7);
/* the struct definitions
*/
-typedef struct /* structure of address conversion */
+typedef struct pci_conv_adr /* structure of address conversion */
{
unsigned long adr; /* calculated address (CPU<->PCI) */
unsigned long len; /* length of memory range */
} PCI_CONV_ADR;
/* structure of resource descriptor */
typedef struct /* structure of resource descriptor */
{
Index: sys/arch/pcibios.S
===================================================================
RCS file: /mint/freemint/sys/arch/pcibios.S,v
retrieving revision 1.1
diff -u -8 -r1.1 pcibios.S
--- sys/arch/pcibios.S 22 Mar 2014 13:10:01 -0000 1.1
+++ sys/arch/pcibios.S 26 Mar 2014 15:18:56 -0000
@@ -12,27 +12,28 @@
* 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
*/
-#ifdef PCI_BIOS
+
.global _tab_funcs_pci
.global _Find_pci_device,_Find_pci_classcode,_Read_config_byte,_Read_config_word,_Read_config_longword
.global _Fast_read_config_byte,_Fast_read_config_word,_Fast_read_config_longword,_Write_config_byte,_Write_config_word,_Write_config_longword
.global _Hook_interrupt,_Unhook_interrupt,_Special_cycle,_Get_routing,_Set_interrupt
.global _Get_resource,_Get_card_used,_Set_card_used,_Read_mem_byte,_Read_mem_word,_Read_mem_longword
.global _Fast_read_mem_byte,_Fast_read_mem_word,_Fast_read_mem_longword,_Write_mem_byte,_Write_mem_word,_Write_mem_longword
.global _Read_io_byte,_Read_io_word,_Read_io_longword,_Fast_read_io_byte,_Fast_read_io_word,_Fast_read_io_longword
.global _Write_io_byte,_Write_io_word,_Write_io_longword,_Get_machine_id
.global _Get_pagesize,_Virt_to_bus,_Bus_to_virt,_Virt_to_phys,_Phys_to_virt
+#ifdef PCI_BIOS
_Find_pci_device:
move.l 4(SP),D0 // ID
move.l 8(SP),D1 // index
move.l _tab_funcs_pci,A1
move.l (A1),A1
move.l D2,-(SP)
jsr (A1)
move.l (SP)+,D2
@@ -420,9 +421,59 @@
move.l 4(SP),D0 // physical CPU address
move.l 8(SP),A0 // ptr
move.l _tab_funcs_pci,A1
move.l 168(A1),A1
move.l D2,-(SP)
jsr (A1)
move.l (SP)+,D2
rts
+#else /* Needed by kentry when PCI_BIOS is undefined */
+.global _pcibios_installed
+
+_Find_pci_device:
+_Find_pci_classcode:
+_Read_config_byte:
+_Read_config_word:
+_Read_config_longword:
+_Fast_read_config_byte:
+_Fast_read_config_word:
+_Fast_read_config_longword:
+_Write_config_byte:
+_Write_config_word:
+_Write_config_longword:
+_Hook_interrupt:
+_Unhook_interrupt:
+_Special_cycle:
+_Get_routing:
+_Set_interrupt:
+_Get_resource:
+_Get_card_used:
+_Set_card_used:
+_Read_mem_byte:
+_Read_mem_word:
+_Read_mem_longword:
+_Fast_read_mem_byte:
+_Fast_read_mem_word:
+_Fast_read_mem_longword:
+_Write_mem_byte:
+_Write_mem_word:
+_Write_mem_longword:
+_Read_io_byte:
+_Read_io_word:
+_Read_io_longword:
+_Fast_read_io_byte:
+_Fast_read_io_word:
+_Fast_read_io_longword:
+_Write_io_byte:
+_Write_io_word:
+_Write_io_longword:
+_Get_machine_id:
+_Get_pagesize:
+_Virt_to_bus:
+_Bus_to_virt:
+_Virt_to_phys:
+_Phys_to_virt:
+ move.l #0xfffff001, d0 // PCI_BIOS_NOT_INSTALLED
+ rts
+
+.lcomm _pcibios_installed 4
#endif /* PCI-BIOS */
Index: sys/libkern/kernel_module.h
===================================================================
RCS file: /mint/freemint/sys/libkern/kernel_module.h,v
retrieving revision 1.48
diff -u -8 -r1.48 kernel_module.h
--- sys/libkern/kernel_module.h 26 Mar 2014 10:16:39 -0000 1.48
+++ sys/libkern/kernel_module.h 26 Mar 2014 15:18:57 -0000
@@ -1055,9 +1055,102 @@
# define xdd_open (*KENTRY->vec_xdd.open)
# define xdd_write (*KENTRY->vec_xdd.write)
# define xdd_read (*KENTRY->vec_xdd.read)
# define xdd_lseek (*KENTRY->vec_xdd.lseek)
# define xdd_ioctl (*KENTRY->vec_xdd.ioctl)
# define xdd_datime (*KENTRY->vec_xdd.datime)
# define xdd_close (*KENTRY->vec_xdd.close)
+/*
+ * kentry_pcibios
+ */
+
+#define pcibios_installed (*KENTRY->vec_pcibios.pcibios_installed)
+#define _Find_pci_device (*KENTRY->vec_pcibios.Find_pci_device)
+#define _Find_pci_classcode (*KENTRY->vec_pcibios.Find_pci_classcode)
+#define _Read_config_byte (*KENTRY->vec_pcibios.Read_config_byte)
+#define _Read_config_word (*KENTRY->vec_pcibios.Read_config_word)
+#define _Read_config_longword (*KENTRY->vec_pcibios.Read_config_longword)
+#define _Fast_read_config_byte (*KENTRY->vec_pcibios.Fast_read_config_byte)
+#define _Fast_read_config_word (*KENTRY->vec_pcibios.Fast_read_config_word)
+#define _Fast_read_config_longword (*KENTRY->vec_pcibios.Fast_read_config_longword)
+#define Write_config_byte (*KENTRY->vec_pcibios.Write_config_byte)
+#define Write_config_word (*KENTRY->vec_pcibios.Write_config_longword)
+#define Write_config_longword (*KENTRY->vec_pcibios.Write_config_longword)
+#define Hook_interrupt (*KENTRY->vec_pcibios.Hook_interrupt)
+#define Unhook_interrupt (*KENTRY->vec_pcibios.Unhook_interrupt)
+#define _Special_cycle (*KENTRY->vec_pcibios.Special_cycle)
+#define Get_routing (*KENTRY->vec_pcibios.Get_routing)
+#define Set_interrupt (*KENTRY->vec_pcibios.Set_interrupt)
+#define Get_resource (*KENTRY->vec_pcibios.Get_resource)
+#define Get_card_used (*KENTRY->vec_pcibios.Get_card_used)
+#define Set_card_used (*KENTRY->vec_pcibios.Set_card_used)
+#define Read_mem_byte (*KENTRY->vec_pcibios.Read_mem_byte)
+#define Read_mem_word (*KENTRY->vec_pcibios.Read_mem_word)
+#define Read_mem_longword (*KENTRY->vec_pcibios.Read_mem_longword)
+#define Fast_read_mem_byte (*KENTRY->vec_pcibios.Fast_read_mem_byte)
+#define Fast_read_mem_word (*KENTRY->vec_pcibios.Fast_read_mem_word)
+#define Fast_read_mem_longword (*KENTRY->vec_pcibios.Fast_read_mem_longword)
+#define _Write_mem_byte (*KENTRY->vec_pcibios.Write_mem_byte)
+#define _Write_mem_word (*KENTRY->vec_pcibios.Write_mem_word)
+#define Write_mem_longword (*KENTRY->vec_pcibios.Write_mem_longword)
+#define Read_io_byte (*KENTRY->vec_pcibios.Read_io_byte)
+#define Read_io_word (*KENTRY->vec_pcibios.Read_io_word)
+#define Read_io_longword (*KENTRY->vec_pcibios.Read_io_longword)
+#define Fast_read_io_byte (*KENTRY->vec_pcibios.Fast_read_io_byte)
+#define Fast_read_io_word (*KENTRY->vec_pcibios.Fast_read_io_word)
+#define Fast_read_io_longword (*KENTRY->vec_pcibios.Fast_read_io_longword)
+#define _Write_io_byte (*KENTRY->vec_pcibios.Write_io_byte)
+#define _Write_io_word (*KENTRY->vec_pcibios.Write_io_word)
+#define Write_io_longword (*KENTRY->vec_pcibios.Write_io_longword)
+#define Get_machine_id (*KENTRY->vec_pcibios.Get_machine_id)
+#define Get_pagesize (*KENTRY->vec_pcibios.Get_pagesize)
+#define Virt_to_bus (*KENTRY->vec_pcibios.Virt_to_bus)
+#define Bus_to_virt (*KENTRY->vec_pcibios.Bus_to_virt)
+#define Virt_to_phys (*KENTRY->vec_pcibios.Virt_to_phys)
+#define Phys_to_virt (*KENTRY->vec_pcibios.Phys_to_virt)
+
+typedef long (*wrap0)();
+typedef long (*wrap1)(long);
+typedef long (*wrap2)(long, long);
+typedef long (*wrap3)(long, long, long);
+
+inline long Find_pci_device(unsigned long id, unsigned short index)
+{ wrap2 f = (wrap2) _Find_pci_device; return (*f)(id, index); }
+
+inline long Find_pci_classcode(unsigned long class, unsigned short index)
+{ wrap2 f = (wrap2) _Find_pci_classcode; return (*f)(class, index); }
+
+inline long Read_config_byte(long handle, unsigned short reg, unsigned char *address)
+{ wrap3 f = (wrap3)_Read_config_byte; return (*f)(handle, reg, (long)address); }
+
+inline long Read_config_word(long handle, unsigned short reg, unsigned short *address)
+{ wrap3 f = (wrap3)_Read_config_word; return (*f)(handle, reg, (long)address); }
+
+inline long Read_config_longword(long handle, unsigned short reg, unsigned long *address)
+{ wrap3 f = (wrap3)_Read_config_longword; return (*f)(handle, reg, (long)address); }
+
+inline unsigned char Fast_read_config_byte(long handle, unsigned short reg)
+{ wrap2 f = (wrap2) _Fast_read_config_byte; return (*f)(handle, reg); }
+
+inline unsigned short Fast_read_config_word(long handle, unsigned short reg)
+{ wrap2 f = (wrap2) _Fast_read_config_word; return (*f)(handle, reg); }
+
+inline unsigned long Fast_read_config_longword(long handle, unsigned short reg)
+{ wrap2 f = (wrap2) _Fast_read_config_longword; return (*f)(handle, reg); }
+
+inline long Special_cycle(unsigned short bus, unsigned long data)
+{ wrap2 f = (wrap2) _Special_cycle; return (*f)(bus, data); }
+
+inline long Write_mem_byte(long handle, unsigned long offset, unsigned short val)
+{ wrap3 f = (wrap3)_Write_mem_byte; return (*f)(handle, offset, val); }
+
+inline long Write_mem_word(long handle, unsigned long offset, unsigned short val)
+{ wrap3 f = (wrap3)_Write_mem_word; return (*f)(handle, offset, val); }
+
+inline long Write_io_byte(long handle, unsigned long offset, unsigned short val)
+{ wrap3 f = (wrap3)_Write_io_byte; return (*f)(handle, offset, val); }
+
+inline long Write_io_word(long handle, unsigned long offset, unsigned short val)
+{ wrap3 f = (wrap3)_Write_io_word; return (*f)(handle, offset, val); }
+
# endif /* _libkern_kernel_module_h */
Index: sys/mint/kentry.h
===================================================================
RCS file: /mint/freemint/sys/mint/kentry.h,v
retrieving revision 1.46
diff -u -8 -r1.46 kentry.h
--- sys/mint/kentry.h 26 Mar 2014 10:16:40 -0000 1.46
+++ sys/mint/kentry.h 26 Mar 2014 15:18:57 -0000
@@ -56,16 +56,17 @@
struct global;
struct ilock;
struct memregion;
struct mfp;
struct module_callback;
struct nf_ops;
struct parser_item;
struct parsinf;
+struct pci_conv_adr;
struct semaphore;
struct timeout;
struct timeval;
/* kentry - kernel entry vector
* ----------------------------
*
@@ -103,17 +104,17 @@
* ----------
* Every structure size modification *must* increase the major version.
* Every other modifcation must increase the minor version.
*
* major and minor are of type unsigned char. I hope 255 major and minor
* versions are enough :-)
*/
#define KENTRY_MAJ_VERSION 0
-#define KENTRY_MIN_VERSION 18
+#define KENTRY_MIN_VERSION 19
/* hardware dependant vector
*/
struct kentry_mch
{
/* global values/flags */
const struct global * const global;
@@ -874,16 +875,110 @@
xdd_write, \
xdd_read, \
xdd_lseek, \
xdd_ioctl, \
xdd_datime, \
xdd_close, \
}
+struct kentry_pcibios
+{
+ unsigned long *pcibios_installed;
+ long _cdecl (*Find_pci_device) (unsigned long id, unsigned short index);
+ long _cdecl (*Find_pci_classcode) (unsigned long class, unsigned short index);
+ long _cdecl (*Read_config_byte) (long handle, unsigned short reg, unsigned char *address);
+ long _cdecl (*Read_config_word) (long handle, unsigned short reg, unsigned short *address);
+ long _cdecl (*Read_config_longword) (long handle, unsigned short reg, unsigned long *address);
+ unsigned char _cdecl (*Fast_read_config_byte) (long handle, unsigned short reg);
+ unsigned short _cdecl (*Fast_read_config_word) (long handle, unsigned short reg);
+ unsigned long _cdecl (*Fast_read_config_longword) (long handle, unsigned short reg);
+ long _cdecl (*Write_config_byte) (long handle, unsigned short reg, unsigned short val);
+ long _cdecl (*Write_config_word) (long handle, unsigned short reg, unsigned short val);
+ long _cdecl (*Write_config_longword) (long handle, unsigned short reg, unsigned long val);
+ long _cdecl (*Hook_interrupt) (long handle, unsigned long *routine, unsigned long *parameter);
+ long _cdecl (*Unhook_interrupt) (long handle);
+ long _cdecl (*Special_cycle) (unsigned short bus, unsigned long data);
+ long _cdecl (*Get_routing) (long handle);
+ long _cdecl (*Set_interrupt) (long handle);
+ long _cdecl (*Get_resource) (long handle);
+ long _cdecl (*Get_card_used) (long handle, unsigned long *address);
+ long _cdecl (*Set_card_used) (long handle, unsigned long *callback);
+ long _cdecl (*Read_mem_byte) (long handle, unsigned long offset, unsigned char *address);
+ long _cdecl (*Read_mem_word) (long handle, unsigned long offset, unsigned short *address);
+ long _cdecl (*Read_mem_longword) (long handle, unsigned long offset, unsigned long *address);
+ unsigned char _cdecl (*Fast_read_mem_byte) (long handle, unsigned long offset);
+ unsigned short _cdecl (*Fast_read_mem_word) (long handle, unsigned long offset);
+ unsigned long _cdecl (*Fast_read_mem_longword) (long handle, unsigned long offset);
+ long _cdecl (*Write_mem_byte) (long handle, unsigned long offset, unsigned short val);
+ long _cdecl (*Write_mem_word) (long handle, unsigned long offset, unsigned short val);
+ long _cdecl (*Write_mem_longword) (long handle, unsigned long offset, unsigned long val);
+ long _cdecl (*Read_io_byte) (long handle, unsigned long offset, unsigned char *address);
+ long _cdecl (*Read_io_word) (long handle, unsigned long offset, unsigned short *address);
+ long _cdecl (*Read_io_longword) (long handle, unsigned long offset, unsigned long *address);
+ unsigned char _cdecl (*Fast_read_io_byte) (long handle, unsigned long offset);
+ unsigned short _cdecl (*Fast_read_io_word) (long handle, unsigned long offset);
+ unsigned long _cdecl (*Fast_read_io_longword) (long handle, unsigned long offset);
+ long _cdecl (*Write_io_byte) (long handle, unsigned long offset, unsigned short val);
+ long _cdecl (*Write_io_word) (long handle, unsigned long offset, unsigned short val);
+ long _cdecl (*Write_io_longword) (long handle, unsigned long offset, unsigned long val);
+ long _cdecl (*Get_machine_id) (void);
+ long _cdecl (*Get_pagesize) (void);
+ long _cdecl (*Virt_to_bus) (long handle, unsigned long address, struct pci_conv_adr *pointer);
+ long _cdecl (*Bus_to_virt) (long handle, unsigned long address, struct pci_conv_adr *pointer);
+ long _cdecl (*Virt_to_phys) (unsigned long address, struct pci_conv_adr *pointer);
+ long _cdecl (*Phys_to_virt) (unsigned long address, struct pci_conv_adr *pointer);
+};
+#define DEFAULTS_kentry_pcibios \
+{ \
+ &pcibios_installed, \
+ Find_pci_device, \
+ Find_pci_classcode, \
+ Read_config_byte, \
+ Read_config_word, \
+ Read_config_longword, \
+ Fast_read_config_byte, \
+ Fast_read_config_word, \
+ Fast_read_config_longword, \
+ Write_config_byte, \
+ Write_config_word, \
+ Write_config_longword, \
+ Hook_interrupt, \
+ Unhook_interrupt, \
+ Special_cycle, \
+ Get_routing, \
+ Set_interrupt, \
+ Get_resource, \
+ Get_card_used, \
+ Set_card_used, \
+ Read_mem_byte, \
+ Read_mem_word, \
+ Read_mem_longword, \
+ Fast_read_mem_byte, \
+ Fast_read_mem_word, \
+ Fast_read_mem_longword, \
+ Write_mem_byte, \
+ Write_mem_word, \
+ Write_mem_longword, \
+ Read_io_byte, \
+ Read_io_word, \
+ Read_io_longword, \
+ Fast_read_io_byte, \
+ Fast_read_io_word, \
+ Fast_read_io_longword, \
+ Write_io_byte, \
+ Write_io_word, \
+ Write_io_longword, \
+ Get_machine_id, \
+ Get_pagesize, \
+ Virt_to_bus, \
+ Bus_to_virt, \
+ Virt_to_phys, \
+ Phys_to_virt, \
+}
/* the complete kernel entry
*/
struct kentry
{
unsigned char major; /* FreeMiNT major version */
unsigned char minor; /* FreeMiNT minor version */
unsigned char patchlevel; /* FreeMiNT patchlevel */
@@ -909,16 +1004,18 @@
struct kentry_module vec_module;
struct kentry_cnf vec_cnf;
struct kentry_misc vec_misc;
struct kentry_debug vec_debug;
struct kentry_libkern vec_libkern;
struct kentry_xfs vec_xfs;
struct kentry_xdd vec_xdd;
+
+ struct kentry_pcibios vec_pcibios;
};
# define DEFAULTS_kentry \
{ \
MINT_MAJ_VERSION, \
MINT_MIN_VERSION, \
MINT_PATCH_LEVEL, \
MINT_STATUS_IDENT, \
\
@@ -938,12 +1035,13 @@
DEFAULTS_kentry_fs, \
DEFAULTS_kentry_sockets, \
DEFAULTS_kentry_module, \
DEFAULTS_kentry_cnf, \
DEFAULTS_kentry_misc, \
DEFAULTS_kentry_debug, \
DEFAULTS_kentry_libkern, \
DEFAULTS_kentry_xfs, \
- DEFAULTS_kentry_xdd \
+ DEFAULTS_kentry_xdd, \
+ DEFAULTS_kentry_pcibios \
}
# endif /* _mint_kentry_h */