summaryrefslogtreecommitdiff
path: root/src/soc/intel/broadwell/refcode/main.c
blob: 7e2e234c5e44a4182bdb6cbb95f02cdf508368a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include "usb.h"
#include "refcode.h"

struct _MRC_PEI_SERVICES;
typedef struct _MRC_PEI_SERVICES MRC_PEI_SERVICES;
struct _refcode_struct;
typedef struct _refcode_struct refcode_struct;

MRC_PEI_SERVICES ** refcode_init(struct pei_data *);
int InstallPchInitPpi(int, MRC_PEI_SERVICES **);
int init_system_agent(int, MRC_PEI_SERVICES **);
int PchInitialize(int, MRC_PEI_SERVICES **);

static inline void*
get_usb_policy(refcode_struct *r)
{
	return (void*)r + 644;
}

static inline uint8_t
get_revision(refcode_struct *r)
{
	return *(uint8_t*)(r);
}

int broadwell_refcode_main(struct pei_data *pei_data)
{
	MRC_PEI_SERVICES **pei_pointer;
	refcode_struct *refcode_struct_ptr;

	pei_pointer = refcode_init(pei_data);
	if (pei_pointer == NULL)
		return -1;

	InstallPchInitPpi(0, pei_pointer);
	init_system_agent(0, pei_pointer);
	PchInitialize(0, pei_pointer);
	refcode_locate_ppi(&refcode_ppi_guid, 0, 0, (void**)(&refcode_struct_ptr));
	PchStartUsbInit(get_usb_policy(refcode_struct_ptr),
			pei_data->ehcibar, pei_data->xhcibar,
			get_revision(refcode_struct_ptr));
	finalize_usb();
	return 0;
}