summaryrefslogtreecommitdiff
path: root/src/framebuffer.s
blob: ef3d9a18be610388189992352313f617d965b4c3 (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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
 * framebuffer.s
 *
 * Copyright © 2018 Thomas White <taw@bitwiz.org.uk>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * 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, see <http://www.gnu.org/licenses/>.
 *
 */

.include "ports.h"

.global framebuffer_init

framebuffer_init:
	STMDB	R13!, {R14}

	ADR	R1, framebuffer_info
	ADD	R1, R1, #0x40000000
	MOV	R0, #1
	BL	send_mailbox
@	BL	read_mailbox

	CMP	R1, #0
	LDMNEIA	R13!, {PC}	@ Fail

	LDMIA	R13!, {PC}


/* ->  R0 = mailbox number
 *     R1 = value to write */
send_mailbox:
	STMDB	R13!, {R2, R8, R14}
	LDR	R8, =(PERIPHERAL_BASE+OFFS_MAILBOX)

	/* Wait for empty mailbox */
1:
	LDR	R2, [R8, #18]
	TST	R2, #1<<31
	BNE	1b

	AND	R2, R0, #0xf
	ORR	R2, R2, R1
	STR	R2, [R8, #20]

	LDMIA	R13!, {R2, R8, PC}


/* -> R0 = mailbox number
 * <- R1 = value read */
read_mailbox:
	STMDB	R13!, {R2, R8, R14}
	LDR	R8, =(PERIPHERAL_BASE+OFFS_MAILBOX)

	/* Wait for non-empty mailbox */
1:
	LDR	R2, [R8, #18]
	TST	R2, #1<<30
	BNE	1b

	LDR	R2, [R8, #0]
	AND	R1, R2, #0xf
	CMP	R1, R0
	BNE	1b		@ Wrong mailbox

	BIC	R1, R2, #0xf

	LDMIA	R13!, {R2, R8, PC}


.align 4
framebuffer_info:
	.int	1024
	.int	768
	.int	1024
	.int	768
	.int	0
	.int	16
	.int	0
	.int	0
	.int	0
	.int	0