Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BadOS Project
BWL
提交
221c8dac
B
BWL
项目概览
BadOS Project
/
BWL
通知
0
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
B
BWL
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
221c8dac
编写于
7月 15, 2022
作者:
指向BIOS的野指针
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
complete functions creating or deleting
pages or frames
上级
fb5f6041
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
89 addition
and
16 deletion
+89
-16
libs/bsv.cc
libs/bsv.cc
+11
-10
libs/bwl.cc
libs/bwl.cc
+78
-6
未找到文件。
libs/bsv.cc
浏览文件 @
221c8dac
...
...
@@ -32,7 +32,7 @@ namespace bwl
__page
*
createPage
(
id_t
pgid
)
{
mkdir
((
PAGEDIR
+
std
::
to_string
(
pgid
)).
c_str
(),
0755
);
int
shmf
=
shm_open
((
PAGEDIR
+
std
::
to_string
(
pgid
)
+
"shm"
).
c_str
(),
O_RDWR
|
O_EXCL
,
0
);
int
shmf
=
shm_open
((
PAGEDIR
+
std
::
to_string
(
pgid
)
+
"
/
shm"
).
c_str
(),
O_RDWR
|
O_EXCL
,
0
);
if
(
shmf
==
-
1
)
{
return
CREATE_PAGE_FAULT
;
...
...
@@ -49,7 +49,7 @@ namespace bwl
if
(
page
!=
(
__page
*
)
-
1
)
{
page
->
pgid
=
pgid
;
shmf
=
shm_open
((
PAGEDIR
+
std
::
to_string
(
pgid
)
+
"bgbuffer"
).
c_str
(),
O_RDWR
|
O_EXCL
,
0
);
shmf
=
shm_open
((
PAGEDIR
+
std
::
to_string
(
pgid
)
+
"
/
bgbuffer"
).
c_str
(),
O_RDWR
|
O_EXCL
,
0
);
if
(
shmf
==
-
1
)
{
return
CREATE_PAGE_FAULT
;
...
...
@@ -63,7 +63,7 @@ namespace bwl
if
(
page
->
server_bg_layer
==
(
void
*
)
-
1
)
{
munmap
(
page
,
sizeof
(
__page
));
shm_unlink
((
PAGEDIR
+
std
::
to_string
(
pgid
)
+
"shm"
).
c_str
());
shm_unlink
((
PAGEDIR
+
std
::
to_string
(
pgid
)
+
"
/
shm"
).
c_str
());
return
(
__page
*
)
MAP_FAILED
;
}
}
...
...
@@ -75,9 +75,9 @@ namespace bwl
{
int
pgid
=
page
->
pgid
;
munmap
(
page
->
server_bg_layer
,
BGBUFSIZE
);
shm_unlink
((
PAGEDIR
+
std
::
to_string
(
pgid
)
+
"bgbuffer"
).
c_str
());
shm_unlink
((
PAGEDIR
+
std
::
to_string
(
pgid
)
+
"
/
bgbuffer"
).
c_str
());
munmap
(
page
,
sizeof
(
__page
));
shm_unlink
((
PAGEDIR
+
std
::
to_string
(
pgid
)
+
"shm"
).
c_str
());
shm_unlink
((
PAGEDIR
+
std
::
to_string
(
pgid
)
+
"
/
shm"
).
c_str
());
rmdir
((
PAGEDIR
+
std
::
to_string
(
pgid
)).
c_str
());
}
...
...
@@ -97,7 +97,7 @@ namespace bwl
__frame
*
createFrame
(
id_t
fid
,
__page
*
page
,
std
::
string
name
,
uint64_t
width
,
uint64_t
height
,
int64_t
x
,
int64_t
y
)
{
mkdir
((
FRMDIR
+
std
::
to_string
(
fid
)).
c_str
(),
0755
);
int
shmf
=
shm_open
((
FRMDIR
+
std
::
to_string
(
fid
)
+
"shm"
).
c_str
(),
O_RDWR
|
O_EXCL
,
0
);
int
shmf
=
shm_open
((
FRMDIR
+
std
::
to_string
(
fid
)
+
"
/
shm"
).
c_str
(),
O_RDWR
|
O_EXCL
,
0
);
if
(
shmf
==
-
1
)
{
return
CREATE_FRAME_FAULT
;
...
...
@@ -126,8 +126,9 @@ namespace bwl
frame
->
size
[
1
]
=
height
;
frame
->
pos
[
0
]
=
x
;
frame
->
pos
[
1
]
=
y
;
frame
->
pixdepth
=
pix_depth
;
shmf
=
shm_open
((
FRMDIR
+
std
::
to_string
(
fid
)
+
"buffer"
).
c_str
(),
O_RDWR
|
O_EXCL
,
0
);
shmf
=
shm_open
((
FRMDIR
+
std
::
to_string
(
fid
)
+
"
/
buffer"
).
c_str
(),
O_RDWR
|
O_EXCL
,
0
);
if
(
shmf
==
-
1
)
{
return
CREATE_FRAME_FAULT
;
...
...
@@ -141,7 +142,7 @@ namespace bwl
if
(
frame
->
server_buf
==
(
void
*
)
-
1
)
{
munmap
(
frame
,
sizeof
(
__frame
));
shm_unlink
((
FRMDIR
+
std
::
to_string
(
fid
)
+
"shm"
).
c_str
());
shm_unlink
((
FRMDIR
+
std
::
to_string
(
fid
)
+
"
/
shm"
).
c_str
());
return
(
__frame
*
)
MAP_FAILED
;
}
}
...
...
@@ -156,9 +157,9 @@ namespace bwl
{
int
fid
=
frame
->
fid
;
munmap
(
frame
->
server_buf
,
frame
->
size
[
0
]
*
frame
->
size
[
1
]
*
pix_depth
);
shm_unlink
((
FRMDIR
+
std
::
to_string
(
fid
)
+
"buffer"
).
c_str
());
shm_unlink
((
FRMDIR
+
std
::
to_string
(
fid
)
+
"
/
buffer"
).
c_str
());
munmap
(
frame
,
sizeof
(
__frame
)
+
frame
->
namelen
);
shm_unlink
((
FRMDIR
+
std
::
to_string
(
fid
)
+
"shm"
).
c_str
());
shm_unlink
((
FRMDIR
+
std
::
to_string
(
fid
)
+
"
/
shm"
).
c_str
());
rmdir
((
FRMDIR
+
std
::
to_string
(
fid
)).
c_str
());
}
...
...
libs/bwl.cc
浏览文件 @
221c8dac
...
...
@@ -48,7 +48,7 @@ namespace bwl
}
host
>>
bad_wayland_server
::
server_pid
;
host
.
close
();
//TODO 向wayland服务器询问屏幕设备大小和像素深度
//
TODO 向wayland服务器询问屏幕设备大小和像素深度
}
uint64_t
getBgBuffSize
()
...
...
@@ -74,7 +74,7 @@ namespace bwl
getting
.
read
((
char
*
)
&
pgid
,
sizeof
(
id_t
));
getting
.
close
();
//获取数据结构
int
shmf
=
std
::
shm_open
((
PAGEDIR
+
std
::
to_string
(
pgid
)
+
"shm"
).
c_str
(),
O_RDWR
|
O_CREAT
,
0
);
int
shmf
=
std
::
shm_open
((
PAGEDIR
+
std
::
to_string
(
pgid
)
+
"
/
shm"
).
c_str
(),
O_RDWR
|
O_CREAT
,
0
);
if
(
shmf
==
-
1
)
{
return
CREATE_PAGE_FAULT
;
...
...
@@ -83,7 +83,7 @@ namespace bwl
std
::
close
(
shmf
);
if
(
page
!=
(
__page
*
)
-
1
)
{
shmf
=
std
::
shm_open
((
PAGEDIR
+
std
::
to_string
(
pgid
)
+
"bgbuffer"
).
c_str
(),
O_RDWR
|
O_CREAT
,
0
);
shmf
=
std
::
shm_open
((
PAGEDIR
+
std
::
to_string
(
pgid
)
+
"
/
bgbuffer"
).
c_str
(),
O_RDWR
|
O_CREAT
,
0
);
if
(
shmf
==
-
1
)
{
return
CREATE_PAGE_FAULT
;
...
...
@@ -93,7 +93,7 @@ namespace bwl
if
(
page
->
client_bg_layer
==
(
void
*
)
-
1
)
{
std
::
munmap
(
page
,
sizeof
(
__page
));
std
::
shm_unlink
((
PAGEDIR
+
std
::
to_string
(
pgid
)
+
"shm"
).
c_str
());
std
::
shm_unlink
((
PAGEDIR
+
std
::
to_string
(
pgid
)
+
"
/
shm"
).
c_str
());
return
(
__page
*
)
MAP_FAILED
;
}
}
...
...
@@ -105,9 +105,9 @@ namespace bwl
{
int
pgid
=
page
->
pgid
;
std
::
munmap
(
page
->
client_bg_layer
,
getBgBuffSize
());
std
::
shm_unlink
((
PAGEDIR
+
std
::
to_string
(
pgid
)
+
"bgbuffer"
).
c_str
());
std
::
shm_unlink
((
PAGEDIR
+
std
::
to_string
(
pgid
)
+
"
/
bgbuffer"
).
c_str
());
std
::
munmap
(
page
,
sizeof
(
__page
));
std
::
shm_unlink
((
PAGEDIR
+
std
::
to_string
(
pgid
)
+
"shm"
).
c_str
());
std
::
shm_unlink
((
PAGEDIR
+
std
::
to_string
(
pgid
)
+
"
/
shm"
).
c_str
());
req_pack
*
rp
=
new
req_pack
;
rp
->
request
=
requests
::
del_page
;
rp
->
pid
=
std
::
getpid
();
...
...
@@ -120,4 +120,76 @@ namespace bwl
delete
rp
;
}
__frame
*
createFrame
(
id_t
fid
,
__page
*
page
,
std
::
string
name
,
uint64_t
width
,
uint64_t
height
,
int64_t
x
,
int64_t
y
)
{
req_pack
*
rp
=
new
req_pack
;
rp
->
request
=
requests
::
create_frame
;
rp
->
pid
=
std
::
getpid
();
rp
->
magic
=
REQMAGIC
;
std
::
memcpy
(
rp
->
arguments
.
a_create_frame
.
name
,
name
.
c_str
(),
name
.
length
());
rp
->
arguments
.
a_create_frame
.
namelen
=
name
.
length
();
rp
->
arguments
.
a_create_frame
.
pgid
=
page
->
pgid
;
rp
->
arguments
.
a_create_frame
.
pos
[
0
]
=
x
;
rp
->
arguments
.
a_create_frame
.
pos
[
1
]
=
y
;
rp
->
arguments
.
a_create_frame
.
size
[
0
]
=
width
;
rp
->
arguments
.
a_create_frame
.
size
[
1
]
=
height
;
rp
->
arguments
.
a_create_frame
.
space
=
colorspace
::
rgb
;
Pipe
push
(
"/dev/bwl/reciever.pipe"
,
bwl
::
Pipe
::
out
);
push
.
write
((
char
*
)
rp
,
sizeof
(
req_pack
));
push
.
close
();
std
::
kill
(
bad_wayland_server
::
server_pid
,
SIGBWLREQ
);
delete
rp
;
//等待服务器回复
Pipe
getting
(
BWLDIR
+
"/reply/"
+
std
::
to_string
(
std
::
getpid
())
+
".pipe"
,
Pipe
::
in
);
getting
.
read
((
char
*
)
&
fid
,
sizeof
(
id_t
));
getting
.
close
();
//映射数据
int
shmf
=
std
::
shm_open
((
FRMDIR
+
std
::
to_string
(
fid
)
+
"/shm"
).
c_str
(),
O_RDWR
|
O_CREAT
,
0
);
if
(
shmf
==
-
1
)
{
return
CREATE_FRAME_FAULT
;
}
__frame
*
frame
=
(
__frame
*
)
std
::
mmap
(
nullptr
,
sizeof
(
__frame
)
+
name
.
length
()
+
1
,
PROT_READ
|
PROT_WRITE
,
MAP_SHARED
,
shmf
,
0
);
std
::
close
(
shmf
);
if
(
frame
!=
(
__frame
*
)
-
1
)
{
shmf
=
std
::
shm_open
((
FRMDIR
+
std
::
to_string
(
fid
)
+
"/buffer"
).
c_str
(),
O_RDWR
|
O_EXCL
,
0
);
if
(
shmf
==
-
1
)
{
return
CREATE_FRAME_FAULT
;
}
frame
->
client_buf
=
std
::
mmap
(
nullptr
,
width
*
height
*
frame
->
pixdepth
,
PROT_READ
|
PROT_WRITE
,
MAP_SHARED
,
shmf
,
0
);
std
::
close
(
shmf
);
if
(
frame
->
client_buf
==
(
void
*
)
-
1
)
{
std
::
munmap
(
frame
,
sizeof
(
__frame
));
std
::
shm_unlink
((
FRMDIR
+
std
::
to_string
(
fid
)
+
"/shm"
).
c_str
());
return
(
__frame
*
)
MAP_FAILED
;
}
}
return
frame
;
}
void
deleteFrame
(
__frame
*
frame
)
{
int
fid
=
frame
->
fid
;
std
::
munmap
(
frame
->
client_buf
,
frame
->
size
[
0
]
*
frame
->
size
[
1
]
*
frame
->
pixdepth
);
std
::
shm_unlink
((
FRMDIR
+
std
::
to_string
(
fid
)
+
"/buffer"
).
c_str
());
std
::
munmap
(
frame
,
sizeof
(
__frame
)
+
frame
->
namelen
);
std
::
shm_unlink
((
FRMDIR
+
std
::
to_string
(
fid
)
+
"/shm"
).
c_str
());
req_pack
*
rp
=
new
req_pack
;
rp
->
request
=
requests
::
del_frame
;
rp
->
pid
=
std
::
getpid
();
rp
->
magic
=
REQMAGIC
;
rp
->
arguments
.
a_del_frame
.
fid
=
fid
;
Pipe
push
(
"/dev/bwl/reciever.pipe"
,
bwl
::
Pipe
::
out
);
push
.
write
((
char
*
)
rp
,
sizeof
(
req_pack
));
push
.
close
();
std
::
kill
(
bad_wayland_server
::
server_pid
,
SIGBWLREQ
);
delete
rp
;
}
};
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录