]>
git.proxmox.com Git - mirror_edk2.git/blob - QuarkSocPkg/QuarkNorthCluster/MemoryInit/Pei/meminit_utils.h
1 /************************************************************************
3 * Copyright (c) 2013-2017 Intel Corporation.
5 * This program and the accompanying materials
6 * are licensed and made available under the terms and conditions of the BSD License
7 * which accompanies this distribution. The full text of the license may be found at
8 * http://opensource.org/licenses/bsd-license.php
10 * THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13 ***************************************************************************/
14 #ifndef _MEMINIT_UTILS_H_
15 #define _MEMINIT_UTILS_H_
17 // General Definitions:
19 #define SAMPLE_SIZE 4 // reduce number of training samples in simulation env
21 #define SAMPLE_SIZE 6 // must be odd number
24 #define EARLY_DB (0x12) // must be less than this number to enable early deadband
25 #define LATE_DB (0x34) // must be greater than this number to enable late deadband
26 #define CHX_REGS (11*4)
33 #define MCEIL(num,den) ((uint8_t)((num+den-1)/den))
34 #define MMAX(a,b) ((((int32_t)(a))>((int32_t)(b)))?(a):(b))
35 #define MCOUNT(a) (sizeof(a)/sizeof(*a))
37 typedef enum ALGOS_enum
{
51 void set_rcvn(uint8_t channel
, uint8_t rank
, uint8_t byte_lane
, uint32_t pi_count
);
52 void set_rdqs(uint8_t channel
, uint8_t rank
, uint8_t byte_lane
, uint32_t pi_count
);
53 void set_wdqs(uint8_t channel
, uint8_t rank
, uint8_t byte_lane
, uint32_t pi_count
);
54 void set_wdq(uint8_t channel
, uint8_t rank
, uint8_t byte_lane
, uint32_t pi_count
);
55 void set_wcmd(uint8_t channel
, uint32_t pi_count
);
56 void set_wclk(uint8_t channel
, uint8_t grp
, uint32_t pi_count
);
57 void set_wctl(uint8_t channel
, uint8_t rank
, uint32_t pi_count
);
58 void set_vref(uint8_t channel
, uint8_t byte_lane
, uint32_t setting
);
59 uint32_t get_rcvn(uint8_t channel
, uint8_t rank
, uint8_t byte_lane
);
60 uint32_t get_rdqs(uint8_t channel
, uint8_t rank
, uint8_t byte_lane
);
61 uint32_t get_wdqs(uint8_t channel
, uint8_t rank
, uint8_t byte_lane
);
62 uint32_t get_wdq(uint8_t channel
, uint8_t rank
, uint8_t byte_lane
);
63 uint32_t get_wcmd(uint8_t channel
);
64 uint32_t get_wclk(uint8_t channel
, uint8_t group
);
65 uint32_t get_wctl(uint8_t channel
, uint8_t rank
);
66 uint32_t get_vref(uint8_t channel
, uint8_t byte_lane
);
68 void clear_pointers(void);
69 void enable_cache(void);
70 void disable_cache(void);
71 void find_rising_edge(MRCParams_t
*mrc_params
, uint32_t delay
[], uint8_t channel
, uint8_t rank
, bool rcvn
);
72 uint32_t sample_dqs(MRCParams_t
*mrc_params
, uint8_t channel
, uint8_t rank
, bool rcvn
);
73 uint32_t get_addr(MRCParams_t
*mrc_params
, uint8_t channel
, uint8_t rank
);
74 uint32_t byte_lane_mask(MRCParams_t
*mrc_params
);
76 uint64_t read_tsc(void);
77 uint32_t get_tsc_freq(void);
78 void delay_n(uint32_t nanoseconds
);
79 void delay_u(uint32_t microseconds
);
80 void delay_m(uint32_t milliseconds
);
81 void delay_s(uint32_t seconds
);
83 void post_code(uint8_t major
, uint8_t minor
);
84 void training_message(uint8_t channel
, uint8_t rank
, uint8_t byte_lane
);
85 void print_timings(MRCParams_t
*mrc_params
);
87 void enable_scrambling(MRCParams_t
*mrc_params
);
88 void store_timings(MRCParams_t
*mrc_params
);
89 void restore_timings(MRCParams_t
*mrc_params
);
90 void default_timings(MRCParams_t
*mrc_params
);
94 // Map memset() and memcpy() to BaseMemoryLib functions
96 #include <Library/BaseMemoryLib.h>
97 #define memset(d,c,n) ((c) == 0) ? ZeroMem ((d), (n)) : SetMem ((d), (n), (c))
98 #define memcpy(d,s,n) CopyMem ((d), (s), (n))
101 #endif // _MEMINIT_UTILS_H_