Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
W
White Rabbit Switch - Software
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
86
Issues
86
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
CI / CD
CI / CD
Pipelines
Schedules
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
White Rabbit Switch - Software
Commits
5715d9cc
Commit
5715d9cc
authored
Mar 07, 2012
by
Tomasz Wlostowski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
userspace/libswitchhw: uploaded missing fpga_io.c (with O_SYNC mmap bugfix)
parent
0fbbbcdd
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
0 deletions
+44
-0
fpga_io.c
userspace/libswitchhw/fpga_io.c
+44
-0
No files found.
userspace/libswitchhw/fpga_io.c
0 → 100644
View file @
5715d9cc
/* Userspace /dev/mem I/O functions for accessing the Main FPGA */
#include <stdio.h>
#include <unistd.h>
#include <unistd.h>
#include <sys/mman.h>
#include <inttypes.h>
#include <fcntl.h>
#include <poll.h>
#include <hw/switch_hw.h>
#define SMC_CS0_BASE 0x10000000
#define SMC_CS0_SIZE 0x200000
#define SPI_CLKDIV_VAL 20 // clock divider for CMI SPI bus clock
/* Virtual base address of the Main FPGA address space. */
volatile
uint8_t
*
_fpga_base_virt
;
/* Initializes the mapping of the Main FPGA to the CPU address space. */
int
shw_fpga_mmap_init
()
{
int
fd
;
TRACE
(
TRACE_INFO
,
"Initializing FPGA memory mapping."
);
fd
=
open
(
"/dev/mem"
,
O_RDWR
|
O_SYNC
);
if
(
!
fd
)
return
-
1
;
_fpga_base_virt
=
mmap
(
NULL
,
SMC_CS0_SIZE
,
PROT_READ
|
PROT_WRITE
,
MAP_SHARED
,
fd
,
SMC_CS0_BASE
);
if
(
_fpga_base_virt
==
NULL
)
{
perror
(
"mmap()"
);
close
(
fd
);
return
-
1
;
}
TRACE
(
TRACE_INFO
,
"FPGA virtual base = 0x%08x"
,
_fpga_base_virt
);
return
0
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment