diff --git a/Targets/Bonito3a9780e/pci/rs780_cmn.c b/Targets/Bonito3a9780e/pci/rs780_cmn.c index f440a7e2..d0563d21 100644 --- a/Targets/Bonito3a9780e/pci/rs780_cmn.c +++ b/Targets/Bonito3a9780e/pci/rs780_cmn.c @@ -25,7 +25,7 @@ #define HT_MAP_TYPE0_CONF_ADDR BONITO_PCICFG0_BASE_VA -typedef unsigned long long u64; +//typedef unsigned long long u64; u32 pci_read_type0_config32(u32 dev, u32 func, u32 reg){ //u64 addr = 0x90000efdfe000000; u32 addr = HT_MAP_TYPE0_CONF_ADDR; diff --git a/pmon/cmds/bootparam.c b/pmon/cmds/bootparam.c index 1f2a6937..86a5f031 100644 --- a/pmon/cmds/bootparam.c +++ b/pmon/cmds/bootparam.c @@ -57,6 +57,9 @@ void init_reset_system(struct efi_reset_system_t *reset) #ifdef LS3A2H_STR reset->ResetCold = LS3A2H_STR_FUNC_ADDR; #endif +#ifdef LOONGSON_3ASINGLE + reset->DoSuspend = 0xffffffffbfc00500; +#endif } void init_smbios(struct smbios_tables *smbios) @@ -218,31 +221,31 @@ void init_loongson_params(struct loongson_params *lp) #else #define PRID_IMP_LOONGSON 0x6306 #endif - enum loongson_cpu_type cputype = Loongson_3B; + enum loongson_cpu_type cputype = Legacy_3B; #endif #ifdef LOONGSON_3BSERVER #define PRID_IMP_LOONGSON 0x6306 - enum loongson_cpu_type cputype = Loongson_3B; + enum loongson_cpu_type cputype = Legacy_3B; #endif #if defined ( LOONGSON_3ASINGLE) || defined ( LOONGSON_3A2H) #define PRID_IMP_LOONGSON 0x6305 - enum loongson_cpu_type cputype = Loongson_3A; + enum loongson_cpu_type cputype = Legacy_3A; #endif #ifdef LOONGSON_3ASERVER #define PRID_IMP_LOONGSON 0x6305 - enum loongson_cpu_type cputype = Loongson_3A; + enum loongson_cpu_type cputype = Legacy_3A; #endif #ifdef LOONGSON_3A84W #define PRID_IMP_LOONGSON 0x146308 - enum loongson_cpu_type cputype = Loongson_3A; + enum loongson_cpu_type cputype = Legacy_3A; #endif #if defined(LOONGSON_2G5536)||defined(LOONGSON_2G1A) #define PRID_IMP_LOONGSON 0x6305 - enum loongson_cpu_type cputype = Loongson_2G; + enum loongson_cpu_type cputype = Legacy_2G; #endif #ifdef LOONGSON_2F1A #define PRID_IMP_LOONGSON 0x6303 - enum loongson_cpu_type cputype = Loongson_2F; + enum loongson_cpu_type cputype = Legacy_2F; #endif struct efi_cpuinfo_loongson *init_cpu_info() @@ -404,7 +407,7 @@ struct interface_info *init_interface_info() tgt_flashinfo((void *)0xbfc00000, &flashsize); - inter->vers = 0x0001; + inter->vers = SPEC_VERS; inter->size = flashsize/0x400; inter->flag = 1; diff --git a/pmon/cmds/bootparam.h b/pmon/cmds/bootparam.h index 39756bf8..4741df3d 100644 --- a/pmon/cmds/bootparam.h +++ b/pmon/cmds/bootparam.h @@ -1,58 +1,46 @@ #ifndef __ASM_MACH_LOONGSON_BOOT_PARAM_H_ #define __ASM_MACH_LOONGSON_BOOT_PARAM_H_ +#include + +typedef unsigned long long u64;//the temporary modification,or need to modify 44 branch.This is not the spec. + +#define SPEC_VERS 0x2 +#define SYSTEM_RAM_LOW 1 +#define SYSTEM_RAM_HIGH 2 +#define MEM_RESERVED 3 +#define PCI_IO 4 +#define PCI_MEM 5 +#define LOONGSON_CFG_REG 6 +#define VIDEO_ROM 7 +#define ADAPTER_ROM 8 +#define ACPI_TABLE 9 +#define SMBIOS_TABLE 10 +#define UMA_VIDEO_RAM 11 +#define MAX_MEMORY_TYPE 12 + +#define VRAM_TYPE_SP 0 +#define VRAM_TYPE_UMA 1 #define DMA64_SUPPORT 0x2 -#define SYSTEM_RAM_LOW 1 -#define SYSTEM_RAM_HIGH 2 -#define MEM_RESERVEI 3 -#define PCI_IO 4 -#define PCI_MEM 5 -#define LOONGSON_CFG_REG 6 -#define VIDEO_ROM 7 -#define DAPTER_ROM 8 -#define ACPI_TABLE 9 -#define SMBIOS_TABLE 10 -#define UMA_VIDEO_RAM 11 -#define MAX_MEMORY_TYPE 12 - - -/*no-use for pmon*/ -struct efi_systab { - // efi_table_hdr_t hdr; /*EFI header*/ - unsigned long long fw_vendor; /* physical addr of CHAR16 vendor string */ - unsigned long long fw_revision; /*vesion of efi*/ - unsigned long long con_in_handle; /*control handle of input*/ - unsigned long long con_in; /*control input,support for inputing in kernel*/ - unsigned long long con_out_handle; /*control handle of input*/ - unsigned long long con_out; /*control input,support for inputing in kernel*/ - unsigned long long stderr_handle; /*standed error handle*/ - // unsigned long stderr; /*standed error */ - // efi_runtime_services_t runtime; /*runtime service */ - unsigned long long boottime; /*boottime */ - unsigned int nr_tables; /*table id*/ - unsigned long long tables; /*all tables `entry */ -}; - -#define BOOT_MEM_MAP_MAX 128 - struct efi_memory_map_loongson{ - unsigned short vers;/*version of efi_memory_map*/ - unsigned int nr_map; /*number of memory_maps*/ - unsigned int mem_freq;/*memory frequence*/ - struct mem_map{ - unsigned int node_id;/*recorde the node_id*/ - unsigned int mem_type;/*recorde the memory type*/ - unsigned long long mem_start;/*memory map start address*/ - unsigned int mem_size; /*for each memory_map size,not the total size*/ - }map[BOOT_MEM_MAP_MAX]; +#define LOONGSON3_BOOT_MEM_MAP_MAX 128 +struct efi_memory_map_loongson{ + u16 vers; /* version of efi_memory_map */ + u32 nr_map; /* number of memory_maps */ + u32 mem_freq; /* memory frequence */ + struct mem_map{ + u32 node_id; /* node_id which memory attached to */ + u32 mem_type; /* system memory, pci memory, pci io, etc. */ + u64 mem_start; /* memory map start address */ + u32 mem_size; /* each memory_map size, not the total size */ + }map[LOONGSON3_BOOT_MEM_MAP_MAX]; }__attribute__((packed)); enum loongson_cpu_type { - Loongson_2F,Loongson_2E, Loongson_3A, Loongson_3B,Loongson_1A,Loongson_1B,Loongson_2G, -/* Legacy_2E = 0x0, - Legacy_2F = 0x1, - Legacy_3A = 0x2, + Legacy_2F = 0x0, + Legacy_2E = 0x1, + Legacy_3A = 0x2, Legacy_3B = 0x3, Legacy_1A = 0x4, Legacy_1B = 0x5, @@ -65,139 +53,176 @@ enum loongson_cpu_type Loongson_2G = 0x202, Loongson_2H = 0x203, Loongson_3A = 0x300, - Loongson_3B = 0x301, */ + Loongson_3B = 0x301 }; +/* + * Capability and feature descriptor structure for MIPS CPU + */ struct efi_cpuinfo_loongson { - /* - * Capability and feature descriptor structure for MIPS CPU - */ - unsigned short vers; /*version of efi_cpuinfo_loongson*/ - unsigned int processor_id;//6505, 6506-3b prid - enum loongson_cpu_type cputype;//3a-3b - unsigned int total_node; /* physical core number */ - - unsigned short cpu_startup_core_id; /* Core id: */ - unsigned short reserved_cores_mask; /* Core id: */ - unsigned int cpu_clock_freq; //cpu_clock - unsigned int nr_cpus; - unsigned char cpuname[64]; /*cpu name*/ + u16 vers; /* version of efi_cpuinfo_loongson */ + u32 processor_id; /* PRID, e.g. 6305, 6306 */ + enum loongson_cpu_type cputype; /* 3A, 3B, etc. */ + u32 total_node; /* num of total numa nodes */ + u16 cpu_startup_core_id; /* Core id */ + u16 reserved_cores_mask; + u32 cpu_clock_freq; /* cpu_clock */ + u32 nr_cpus; + u8 cpuname[64]; /*cpu name*/ + +}__attribute__((packed)); + +#define MAX_UARTS 64 +struct uart_device { + u32 iotype; /* see include/linux/serial_core.h */ + u32 uartclk; + u32 int_offset; + u64 uart_base; }__attribute__((packed)); +#define MAX_SENSORS 64 +#define SENSOR_TEMPER 0x00000001 +#define SENSOR_VOLTAGE 0x00000002 +#define SENSOR_FAN 0x00000004 +struct sensor_device { + char name[32]; /* a formal name */ + char label[64]; /* a flexible description */ + u32 type; /* SENSOR_* */ + u32 id; /* instance id of a sensor-class */ + u32 fan_policy; /* see arch/mips/include/asm/mach-loongson/loongson_hwmon.h */ + u32 fan_percent;/* only for constant speed policy */ + u64 base_addr; /* base address of device registers */ +}__attribute__((packed)); struct system_loongson{ - unsigned short vers;/*version of system_loongson*/ - unsigned int ccnuma_smp; // 0:no numa; 1: has numa - unsigned int sing_double_channel;//1:single; 2:double + u16 vers; /* version of system_loongson */ + u32 ccnuma_smp; /* 0: no numa; 1: has numa */ + u32 sing_double_channel; /* 1:single; 2:double */ + u32 nr_uarts; + struct uart_device uarts[MAX_UARTS]; + u32 nr_sensors; + struct sensor_device sensors[MAX_SENSORS]; + char has_ec; + char ec_name[32]; + u64 ec_base_addr; + char has_tcm; + char tcm_name[32]; + u64 tcm_base_addr; + u64 workarounds; /* see workarounds.h */ }__attribute__((packed)); struct irq_source_routing_table { - - unsigned short vers; - unsigned short size; - unsigned short bus,devfn; - unsigned int vendor,device, PIC_type; //conform use HT or PCI to route to CPU-PIC - - unsigned long long ht_int_bit; //3a: 1<<24; 3b:1<<16 - unsigned long long ht_enable; //irqs used in this PIC.eg:3a-0x0000d17a - unsigned int node_id; // node id, 0x0 —0, 0x1—1; 0x10—2;0x11—3;0x100—4 - - unsigned long long pci_mem_start_addr; - unsigned long long pci_mem_end_addr; - unsigned long long pci_io_start_addr; - unsigned long long pci_io_end_addr; - unsigned long long pci_config_addr; - unsigned short dma_mask_bits; - unsigned short dma_noncoherent;/* 0:cache DMA ; 1:uncache DMA */ - + u16 vers; + u16 size; + u16 rtr_bus; + u16 rtr_devfn; + u32 vendor; + u32 device; + u32 PIC_type; /* conform use HT or PCI to route to CPU-PIC */ + u64 ht_int_bit; /* 3A: 1<<24; 3B: 1<<16 */ + u64 ht_enable; /* irqs used in this PIC */ + u32 node_id; /* node id: 0x0-0; 0x1-1; 0x10-2; 0x11-3 */ + u64 pci_mem_start_addr; + u64 pci_mem_end_addr; + u64 pci_io_start_addr; + u64 pci_io_end_addr; + u64 pci_config_addr; + u16 dma_mask_bits; + u16 dma_noncoherent;/* 0:cache DMA ; 1:uncache DMA */ }__attribute__((packed)); - struct interface_info{ - unsigned short vers; /*version of the specificition*/ - unsigned short size; /**/ - unsigned char flag;/**/ - char description[64]; /**/ + u16 vers; /* version of the specificition */ + u16 size; + u8 flag; + char description[64]; }__attribute__((packed)); - -#define MAX_RESOUCR_NUMBER 128 +#define MAX_RESOURCE_NUMBER 128 struct resource_loongson { - unsigned long long start; /*resource start address*/ - unsigned long long end; /*resource end address*/ - char name[64]; - unsigned int flags; + u64 start; /* resource start address */ + u64 end; /* resource end address */ + char name[64]; + u32 flags; }; -struct archdev_data {}; /*arch specific additions*/ +struct archdev_data {}; /* arch specific additions */ struct board_devices{ - char name[64]; /*hold the device name*/ - unsigned int num_resources; /*number of device_resource*/ - struct resource_loongson resource[MAX_RESOUCR_NUMBER]; /*for each device`s resource*/ - /*arch specific additions*/ - struct archdev_data archdata; + char name[64]; /* hold the device name */ + u32 num_resources; /* number of device_resource */ + struct resource_loongson resource[MAX_RESOURCE_NUMBER]; /* for each device's resource */ + /* arch specific additions */ + struct archdev_data archdata; }; struct loongson_special_attribute{ - unsigned short vers; /*version of this special*/ - char special_name[64]; /*special_atribute_name*/ - unsigned int loongson_special_type; /*tyoe of special device*/ - struct resource_loongson resource[MAX_RESOUCR_NUMBER];/*special_vlaue resource*/ + u16 vers; /* version of this special */ + char special_name[64]; /* special_atribute_name */ + u32 loongson_special_type; /* type of special device */ + struct resource_loongson resource[MAX_RESOURCE_NUMBER]; /* for each device's resource */ }; struct loongson_params{ - unsigned long long memory_offset;/*efi_memory_map_loongson struct offset*/ - unsigned long long cpu_offset; /*efi_cpuinfo_loongson struct offset*/ - unsigned long long system_offset; /*system_info struct offset*/ - unsigned long long irq_offset; /*irq_source_routing_table struct offset*/ - unsigned long long interface_offset; /*interface_info struct offset*/ - unsigned long long special_offset; /*loongson_special_attribute struct offset*/ - unsigned long long boarddev_table_offset; /*board_device offset*/ + u64 memory_offset; /* efi_memory_map_loongson struct offset */ + u64 cpu_offset; /* efi_cpuinfo_loongson struct offset */ + u64 system_offset; /* system_loongson struct offset */ + u64 irq_offset; /* irq_source_routing_table struct offset */ + u64 interface_offset; /* interface_info struct offset */ + u64 special_offset; /* loongson_special_attribute struct offset */ + u64 boarddev_table_offset; /* board_devices offset */ }; struct smbios_tables { - unsigned short vers; /*version of smbios*/ - unsigned long long vga_bios;/*vga_bios address*/ + u16 vers; /* version of smbios */ + u64 vga_bios; /* vga_bios address */ struct loongson_params lp; }; -struct efi_reset_system_t -{ - unsigned long long ResetCold; - unsigned long long ResetWarm; - unsigned long long ResetType; - unsigned long long Shutdown; - unsigned long long DoSuspend; +struct efi_reset_system_t{ + u64 ResetCold; + u64 ResetWarm; + u64 ResetType; + u64 Shutdown; + u64 DoSuspend; /* NULL if not support */ }; struct efi_loongson { - //efi_system_table_t systab; /* EFI system table */ - unsigned long long mps; /* MPS table */ - unsigned long long acpi; /* ACPI table (IA64 ext 0.71) */ - unsigned long long acpi20; /* ACPI table (ACPI 2.0) */ - struct smbios_tables smbios; /* SM BIOS table */ - unsigned long long sal_systab; /* SAL system table */ - unsigned long long boot_info; /* boot info table */ - /*have non this struct for stage1-1 - efi_get_time_t *get_time; - efi_set_time_t *set_time; - efi_get_wakeup_time_t *get_wakeup_time; - efi_set_wakeup_time_t *set_wakeup_time; - efi_get_variable_t *get_variable; - efi_get_next_variable_t *get_next_variable; - efi_set_variable_t *set_variable; - efi_get_next_high_mono_count_t *get_next_high_mono_count; - efi_reset_system_t *reset_system; - efi_set_virtual_address_map_t *set_virtual_address_map; - */ + u64 mps; /* MPS table */ + u64 acpi; /* ACPI table (IA64 ext 0.71) */ + u64 acpi20; /* ACPI table (ACPI 2.0) */ + struct smbios_tables smbios; /* SM BIOS table */ + u64 sal_systab; /* SAL system table */ + u64 boot_info; /* boot info table */ }; struct boot_params{ - //struct screen_info *screen_info; - //struct sys_desc_table *sys_desc_table; struct efi_loongson efi; - struct efi_reset_system_t reset_system; + struct efi_reset_system_t reset_system; }; +extern u32 nr_cpus_loongson; +extern u32 nr_nodes_loongson; +extern int cores_per_node; +extern int cores_per_package; +extern enum loongson_cpu_type cputype; +extern u16 loongson_boot_cpu_id; +extern u16 loongson_reserved_cpus_mask; +extern struct efi_memory_map_loongson *emap; +extern u64 ht_control_base; +extern u64 pci_mem_start_addr, pci_mem_end_addr; +extern u64 loongson_pciio_base; +extern u64 vgabios_addr; +extern u64 low_physmem_start; +extern u64 high_physmem_start; +extern u32 vram_type; +extern u64 uma_vram_addr; +extern u64 uma_vram_size; + +extern u32 loongson_nr_uarts; +extern struct uart_device loongson_uarts[MAX_UARTS]; +extern u32 loongson_ec_sci_irq; +extern char loongson_ecname[32]; +extern u32 loongson_nr_sensors; +extern struct sensor_device loongson_sensors[MAX_SENSORS]; #endif diff --git a/sys/linux/types.h b/sys/linux/types.h index cc67c859..3bcf7724 100644 --- a/sys/linux/types.h +++ b/sys/linux/types.h @@ -10,6 +10,18 @@ typedef signed char s8; typedef signed short s16; typedef signed long s32; +/* +#if (_MIPS_SZPTR == 64) + typedef __signed__ long s64; + typedef unsigned long u64; +#else + #if defined(__GNUC__) && !defined(__STRICT_ANSI__) + typedef __signed__ long long s64; + typedef unsigned long long u64; + #endif +#endif +*/ + typedef signed int sint; typedef signed long slong;