Add skeleton machine dependent headers and c files for a port of freebsd
to a new architecture. This is the base of the sparc64 port, but contains
limited machine dependent code, and can be used a base for ports. Included
are:
- standard machine dependent headers, tweaked for a 64 bit, big endian
architecture, including empty versions of all the machine dependent
structures
- a machine independent atomic.h, which can be used until a port has
support for interrupts and the operations really need to be atomic
- stub versions of all the machine dependent functions, which panic
when called and print out the name of the function that needs to
be implemented. functions which are normally in assembly files are
not included, but this should reduce the number of different undefined
references on the first few compiles from hundreds to 5 or 6
Given minimal startup code and console support it should be trivial to
make this compile and run the first few sysinits on almost any architecture.
Requested by: alfred, imp, jhb
2001-07-31 05:45:16 +00:00
|
|
|
/*-
|
|
|
|
* Copyright (c) 2001 Jake Burkholder.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
2001-08-09 02:09:34 +00:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
Add skeleton machine dependent headers and c files for a port of freebsd
to a new architecture. This is the base of the sparc64 port, but contains
limited machine dependent code, and can be used a base for ports. Included
are:
- standard machine dependent headers, tweaked for a 64 bit, big endian
architecture, including empty versions of all the machine dependent
structures
- a machine independent atomic.h, which can be used until a port has
support for interrupts and the operations really need to be atomic
- stub versions of all the machine dependent functions, which panic
when called and print out the name of the function that needs to
be implemented. functions which are normally in assembly files are
not included, but this should reduce the number of different undefined
references on the first few compiles from hundreds to 5 or 6
Given minimal startup code and console support it should be trivial to
make this compile and run the first few sysinits on almost any architecture.
Requested by: alfred, imp, jhb
2001-07-31 05:45:16 +00:00
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
2001-08-09 02:09:34 +00:00
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
Add skeleton machine dependent headers and c files for a port of freebsd
to a new architecture. This is the base of the sparc64 port, but contains
limited machine dependent code, and can be used a base for ports. Included
are:
- standard machine dependent headers, tweaked for a 64 bit, big endian
architecture, including empty versions of all the machine dependent
structures
- a machine independent atomic.h, which can be used until a port has
support for interrupts and the operations really need to be atomic
- stub versions of all the machine dependent functions, which panic
when called and print out the name of the function that needs to
be implemented. functions which are normally in assembly files are
not included, but this should reduce the number of different undefined
references on the first few compiles from hundreds to 5 or 6
Given minimal startup code and console support it should be trivial to
make this compile and run the first few sysinits on almost any architecture.
Requested by: alfred, imp, jhb
2001-07-31 05:45:16 +00:00
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* $FreeBSD$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _MACHINE_SMP_H_
|
|
|
|
#define _MACHINE_SMP_H_
|
|
|
|
|
2002-03-04 07:12:36 +00:00
|
|
|
#define CPU_CLKSYNC 1
|
|
|
|
#define CPU_INIT 2
|
|
|
|
#define CPU_BOOTSTRAP 3
|
2002-01-08 05:50:26 +00:00
|
|
|
|
|
|
|
#ifndef LOCORE
|
|
|
|
|
2002-02-23 18:41:34 +00:00
|
|
|
#include <machine/intr_machdep.h>
|
2002-03-04 07:12:36 +00:00
|
|
|
#include <machine/tte.h>
|
2002-02-23 18:41:34 +00:00
|
|
|
|
2002-01-08 05:50:26 +00:00
|
|
|
#define IDR_BUSY (1<<0)
|
|
|
|
#define IDR_NACK (1<<1)
|
|
|
|
|
|
|
|
#define IPI_AST PIL_AST
|
|
|
|
#define IPI_RENDEZVOUS PIL_RENDEZVOUS
|
|
|
|
#define IPI_STOP PIL_STOP
|
|
|
|
|
|
|
|
#define IPI_RETRIES 100
|
|
|
|
|
|
|
|
struct cpu_start_args {
|
2002-03-07 06:01:40 +00:00
|
|
|
u_int csa_count;
|
2002-01-08 05:50:26 +00:00
|
|
|
u_int csa_mid;
|
|
|
|
u_int csa_state;
|
2002-03-07 06:01:40 +00:00
|
|
|
vm_offset_t csa_pcpu;
|
2002-03-04 07:12:36 +00:00
|
|
|
u_long csa_tick;
|
|
|
|
u_long csa_ver;
|
|
|
|
struct tte csa_ttes[PCPU_PAGES];
|
2002-01-08 05:50:26 +00:00
|
|
|
};
|
|
|
|
|
2002-05-20 16:30:47 +00:00
|
|
|
struct ipi_cache_args {
|
|
|
|
u_int ica_mask;
|
|
|
|
u_long ica_pa;
|
|
|
|
};
|
|
|
|
|
2002-01-08 05:50:26 +00:00
|
|
|
struct ipi_tlb_args {
|
2002-03-13 03:43:00 +00:00
|
|
|
u_int ita_mask;
|
2002-03-07 06:01:40 +00:00
|
|
|
struct pmap *ita_pmap;
|
2002-01-08 05:50:26 +00:00
|
|
|
u_long ita_start;
|
|
|
|
u_long ita_end;
|
|
|
|
};
|
|
|
|
#define ita_va ita_start
|
|
|
|
|
|
|
|
struct pcpu;
|
|
|
|
|
|
|
|
void cpu_mp_bootstrap(struct pcpu *pc);
|
2002-03-13 03:43:00 +00:00
|
|
|
void cpu_mp_shutdown(void);
|
2002-01-08 05:50:26 +00:00
|
|
|
|
|
|
|
void cpu_ipi_selected(u_int cpus, u_long d0, u_long d1, u_long d2);
|
|
|
|
void cpu_ipi_send(u_int mid, u_long d0, u_long d1, u_long d2);
|
|
|
|
|
|
|
|
void ipi_selected(u_int cpus, u_int ipi);
|
|
|
|
void ipi_all(u_int ipi);
|
|
|
|
void ipi_all_but_self(u_int ipi);
|
|
|
|
|
2002-03-04 07:12:36 +00:00
|
|
|
vm_offset_t mp_tramp_alloc(void);
|
|
|
|
|
2002-12-22 20:50:23 +00:00
|
|
|
extern struct mtx ipi_mtx;
|
|
|
|
extern struct ipi_cache_args ipi_cache_args;
|
|
|
|
extern struct ipi_tlb_args ipi_tlb_args;
|
2002-01-08 05:50:26 +00:00
|
|
|
|
2002-03-04 07:12:36 +00:00
|
|
|
extern vm_offset_t mp_tramp;
|
|
|
|
extern char *mp_tramp_code;
|
|
|
|
extern u_long mp_tramp_code_len;
|
|
|
|
extern u_long mp_tramp_tlb_slots;
|
|
|
|
extern u_long mp_tramp_func;
|
|
|
|
|
|
|
|
extern void mp_startup(void);
|
|
|
|
|
2002-05-20 16:30:47 +00:00
|
|
|
extern char tl_ipi_dcache_page_inval[];
|
|
|
|
extern char tl_ipi_icache_page_inval[];
|
2002-01-08 05:50:26 +00:00
|
|
|
extern char tl_ipi_level[];
|
|
|
|
extern char tl_ipi_tlb_context_demap[];
|
|
|
|
extern char tl_ipi_tlb_page_demap[];
|
|
|
|
extern char tl_ipi_tlb_range_demap[];
|
|
|
|
|
|
|
|
#ifdef SMP
|
|
|
|
|
2002-12-22 20:50:23 +00:00
|
|
|
#if defined(_MACHINE_PMAP_H_) && defined(_SYS_MUTEX_H_)
|
|
|
|
|
2002-05-20 16:30:47 +00:00
|
|
|
static __inline void *
|
|
|
|
ipi_dcache_page_inval(vm_offset_t pa)
|
|
|
|
{
|
|
|
|
struct ipi_cache_args *ica;
|
|
|
|
|
|
|
|
if (smp_cpus == 1)
|
|
|
|
return (NULL);
|
|
|
|
ica = &ipi_cache_args;
|
2002-12-22 20:50:23 +00:00
|
|
|
mtx_lock_spin(&ipi_mtx);
|
2002-05-20 16:30:47 +00:00
|
|
|
ica->ica_mask = all_cpus;
|
|
|
|
ica->ica_pa = pa;
|
2002-07-12 16:26:49 +00:00
|
|
|
cpu_ipi_selected(PCPU_GET(other_cpus), 0,
|
|
|
|
(u_long)tl_ipi_dcache_page_inval, (u_long)ica);
|
2002-05-20 16:30:47 +00:00
|
|
|
return (&ica->ica_mask);
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline void *
|
|
|
|
ipi_icache_page_inval(vm_offset_t pa)
|
|
|
|
{
|
|
|
|
struct ipi_cache_args *ica;
|
|
|
|
|
|
|
|
if (smp_cpus == 1)
|
|
|
|
return (NULL);
|
|
|
|
ica = &ipi_cache_args;
|
2002-12-22 20:50:23 +00:00
|
|
|
mtx_lock_spin(&ipi_mtx);
|
2002-05-20 16:30:47 +00:00
|
|
|
ica->ica_mask = all_cpus;
|
|
|
|
ica->ica_pa = pa;
|
2002-07-12 16:26:49 +00:00
|
|
|
cpu_ipi_selected(PCPU_GET(other_cpus), 0,
|
|
|
|
(u_long)tl_ipi_icache_page_inval, (u_long)ica);
|
2002-05-20 16:30:47 +00:00
|
|
|
return (&ica->ica_mask);
|
|
|
|
}
|
|
|
|
|
2002-01-08 05:50:26 +00:00
|
|
|
static __inline void *
|
2002-03-07 06:01:40 +00:00
|
|
|
ipi_tlb_context_demap(struct pmap *pm)
|
2002-01-08 05:50:26 +00:00
|
|
|
{
|
|
|
|
struct ipi_tlb_args *ita;
|
2002-03-07 06:01:40 +00:00
|
|
|
u_int cpus;
|
2002-01-08 05:50:26 +00:00
|
|
|
|
2002-03-07 06:01:40 +00:00
|
|
|
if (smp_cpus == 1)
|
|
|
|
return (NULL);
|
|
|
|
if ((cpus = (pm->pm_active & PCPU_GET(other_cpus))) == 0)
|
2002-01-08 05:50:26 +00:00
|
|
|
return (NULL);
|
|
|
|
ita = &ipi_tlb_args;
|
2002-12-22 20:50:23 +00:00
|
|
|
mtx_lock_spin(&ipi_mtx);
|
2002-03-13 03:43:00 +00:00
|
|
|
ita->ita_mask = cpus | PCPU_GET(cpumask);
|
2002-03-07 06:01:40 +00:00
|
|
|
ita->ita_pmap = pm;
|
|
|
|
cpu_ipi_selected(cpus, 0, (u_long)tl_ipi_tlb_context_demap,
|
|
|
|
(u_long)ita);
|
2002-03-13 03:43:00 +00:00
|
|
|
return (&ita->ita_mask);
|
2002-01-08 05:50:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static __inline void *
|
2002-07-26 15:54:04 +00:00
|
|
|
ipi_tlb_page_demap(struct pmap *pm, vm_offset_t va)
|
2002-01-08 05:50:26 +00:00
|
|
|
{
|
|
|
|
struct ipi_tlb_args *ita;
|
2002-03-07 06:01:40 +00:00
|
|
|
u_int cpus;
|
2002-01-08 05:50:26 +00:00
|
|
|
|
2002-03-07 06:01:40 +00:00
|
|
|
if (smp_cpus == 1)
|
|
|
|
return (NULL);
|
|
|
|
if ((cpus = (pm->pm_active & PCPU_GET(other_cpus))) == 0)
|
2002-01-08 05:50:26 +00:00
|
|
|
return (NULL);
|
|
|
|
ita = &ipi_tlb_args;
|
2002-12-22 20:50:23 +00:00
|
|
|
mtx_lock_spin(&ipi_mtx);
|
2002-03-13 03:43:00 +00:00
|
|
|
ita->ita_mask = cpus | PCPU_GET(cpumask);
|
2002-03-07 06:01:40 +00:00
|
|
|
ita->ita_pmap = pm;
|
2002-01-08 05:50:26 +00:00
|
|
|
ita->ita_va = va;
|
2002-03-07 06:01:40 +00:00
|
|
|
cpu_ipi_selected(cpus, 0, (u_long)tl_ipi_tlb_page_demap, (u_long)ita);
|
2002-03-13 03:43:00 +00:00
|
|
|
return (&ita->ita_mask);
|
2002-01-08 05:50:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static __inline void *
|
2002-03-07 06:01:40 +00:00
|
|
|
ipi_tlb_range_demap(struct pmap *pm, vm_offset_t start, vm_offset_t end)
|
2002-01-08 05:50:26 +00:00
|
|
|
{
|
|
|
|
struct ipi_tlb_args *ita;
|
2002-03-07 06:01:40 +00:00
|
|
|
u_int cpus;
|
2002-01-08 05:50:26 +00:00
|
|
|
|
2002-03-07 06:01:40 +00:00
|
|
|
if (smp_cpus == 1)
|
|
|
|
return (NULL);
|
|
|
|
if ((cpus = (pm->pm_active & PCPU_GET(other_cpus))) == 0)
|
2002-01-08 05:50:26 +00:00
|
|
|
return (NULL);
|
|
|
|
ita = &ipi_tlb_args;
|
2002-12-22 20:50:23 +00:00
|
|
|
mtx_lock_spin(&ipi_mtx);
|
2002-03-13 03:43:00 +00:00
|
|
|
ita->ita_mask = cpus | PCPU_GET(cpumask);
|
2002-03-07 06:01:40 +00:00
|
|
|
ita->ita_pmap = pm;
|
2002-01-08 05:50:26 +00:00
|
|
|
ita->ita_start = start;
|
|
|
|
ita->ita_end = end;
|
2002-03-07 06:01:40 +00:00
|
|
|
cpu_ipi_selected(cpus, 0, (u_long)tl_ipi_tlb_range_demap, (u_long)ita);
|
2002-03-13 03:43:00 +00:00
|
|
|
return (&ita->ita_mask);
|
2002-01-08 05:50:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static __inline void
|
|
|
|
ipi_wait(void *cookie)
|
|
|
|
{
|
2002-03-13 03:43:00 +00:00
|
|
|
u_int *volatile mask;
|
2002-01-08 05:50:26 +00:00
|
|
|
|
2002-03-13 03:43:00 +00:00
|
|
|
if ((mask = cookie) != NULL) {
|
|
|
|
atomic_clear_int(mask, PCPU_GET(cpumask));
|
|
|
|
while (*mask != 0)
|
2002-03-04 07:12:36 +00:00
|
|
|
;
|
2002-12-22 20:50:23 +00:00
|
|
|
mtx_unlock_spin(&ipi_mtx);
|
2002-01-08 05:50:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-12-22 20:50:23 +00:00
|
|
|
#endif /* _MACHINE_PMAP_H_ && _SYS_MUTEX_H_ */
|
2002-03-07 06:01:40 +00:00
|
|
|
|
2002-01-08 05:50:26 +00:00
|
|
|
#else
|
|
|
|
|
2002-05-20 16:30:47 +00:00
|
|
|
static __inline void *
|
|
|
|
ipi_dcache_page_inval(vm_offset_t pa)
|
|
|
|
{
|
|
|
|
return (NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline void *
|
|
|
|
ipi_icache_page_inval(vm_offset_t pa)
|
|
|
|
{
|
|
|
|
return (NULL);
|
|
|
|
}
|
|
|
|
|
2002-01-08 05:50:26 +00:00
|
|
|
static __inline void *
|
2002-03-07 06:01:40 +00:00
|
|
|
ipi_tlb_context_demap(struct pmap *pm)
|
2002-01-08 05:50:26 +00:00
|
|
|
{
|
|
|
|
return (NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline void *
|
2002-07-26 15:54:04 +00:00
|
|
|
ipi_tlb_page_demap(struct pmap *pm, vm_offset_t va)
|
2002-01-08 05:50:26 +00:00
|
|
|
{
|
|
|
|
return (NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline void *
|
2002-03-07 06:01:40 +00:00
|
|
|
ipi_tlb_range_demap(struct pmap *pm, vm_offset_t start, vm_offset_t end)
|
2002-01-08 05:50:26 +00:00
|
|
|
{
|
|
|
|
return (NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline void
|
|
|
|
ipi_wait(void *cookie)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* SMP */
|
|
|
|
|
|
|
|
#endif /* !LOCORE */
|
|
|
|
|
Add skeleton machine dependent headers and c files for a port of freebsd
to a new architecture. This is the base of the sparc64 port, but contains
limited machine dependent code, and can be used a base for ports. Included
are:
- standard machine dependent headers, tweaked for a 64 bit, big endian
architecture, including empty versions of all the machine dependent
structures
- a machine independent atomic.h, which can be used until a port has
support for interrupts and the operations really need to be atomic
- stub versions of all the machine dependent functions, which panic
when called and print out the name of the function that needs to
be implemented. functions which are normally in assembly files are
not included, but this should reduce the number of different undefined
references on the first few compiles from hundreds to 5 or 6
Given minimal startup code and console support it should be trivial to
make this compile and run the first few sysinits on almost any architecture.
Requested by: alfred, imp, jhb
2001-07-31 05:45:16 +00:00
|
|
|
#endif /* !_MACHINE_SMP_H_ */
|